Giter VIP home page Giter VIP logo

django-dynamodb-sessions's Introduction

django-dynamodb-sessions

Info

This package contains a simple Django session backend that uses Amazon's DynamoDB for data storage.

Author

Greg Taylor

Status

Stable, but un-maintained (Open an issue if interested in maintaining!)

Status

django-dynamodb-sessions has seen some use on small test environments within EC2. While it should be ready for prime time, it hasn't been heavily battle tested just yet. Other notes:

  • There is currently no management command to remove expired sessions. We can't re-use the Django cleanup command, so we'll have to write our own. This will be added in the next release, we're already setting expiration attributes to drive the cleanup.

Set up your DynamoDB Table

Before you can use this module, you'll need to visit your DynamoDB tab in the AWS Management Console. Then:

  • Hit the Create Table button.
  • Enter sessions as your table name. This can be something else, you'll just need to adjust the settings.DYNAMODB_SESSIONS_TABLE_NAME value accordingly.
  • Select Primary Key Type = Hash.
  • Select a String hash attribute type.
  • Enter session_key for Hash Attribute Name.
  • Hit the Continue button.
  • Decide on throughput. The free tier is 10 read capacity units, 5 write.
  • Finish the rest of the steps

After your table is created, you're ready to install the module on your Django app.

Installation

Install django-dynamodb-sessions using pip or easy_install:

pip install django-dynamodb-sessions

In your settings.py file, you'll need something like this:

DYNAMODB_SESSIONS_AWS_ACCESS_KEY_ID = 'YourKeyIDHere'
DYNAMODB_SESSIONS_AWS_SECRET_ACCESS_KEY = 'YourSecretHere'

If you'd like to add a caching layer between your application and DynamoDB to reduce queries (like Django's cached_db backend), set your session backend to:

SESSION_ENGINE = 'dynamodb_sessions.backends.cached_dynamodb'

Otherwise, go straight to DynamoDB:

SESSION_ENGINE = 'dynamodb_sessions.backends.dynamodb'

After that, fire her up and keep an eye on your Amazon Management Console to see if you need to scale your read/write units up or down.

If you encounter any bugs, have questions, or would like to share an idea, hit up our issue tracker.

Configuration

The following settings may be used in your settings.py:

DYNAMODB_SESSIONS_TABLE_NAME

The table name to use for session data storage. Defaults to sessions.

DYNAMODB_SESSIONS_TABLE_HASH_ATTRIB_NAME

The hash attribute name on your session table. Defaults to session_key

DYNAMODB_SESSIONS_ALWAYS_CONSISTENT

If you're not using this session backend behind a cache, you may want to force all reads from DynamoDB to be consistent. This may lead to slightly slower queries, but you'll never miss object creation/edits. Defaults to True.

DYNAMODB_SESSIONS_BOTO_SESSION

Used instead of providing access_key and region, the boto3.session.Session containing authentication for the AWS account to use for DynamoDB.

DYNAMODB_SESSIONS_AWS_ACCESS_KEY_ID

The access key for the AWS account to use for DynamoDB.

DYNAMODB_SESSIONS_AWS_SECRET_ACCESS_KEY

The secret for the AWS account to use for DynamoDB.

DYNAMODB_SESSIONS_AWS_REGION_NAME

The region to use for DynamoDB.

Changes

0.7

  • Switch to boto3 rather than boto for AWS access.
  • Allow passing of boto3 session rather than AWS credentials.

0.6

  • Removing some no longer used imports.
  • PEP8 cleanup.

0.5

  • Replacing self.session_key with self._session_key in the backend. (AdamN)

0.4

  • Django 1.4 compatibility, and unnecessary code removal. (AdamN)

0.3

  • Re-packaging with setuptools instead of distutils.

0.2

  • Correcting an issue with the cached_dynamodb backend.

0.1

  • Initial release.

License

django-dynamodb-sessions is licensed under the BSD License.

django-dynamodb-sessions's People

Contributors

bjinwright avatar ehooo avatar gtaylor avatar philwitty avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.