gredis - a redis extension for glim

gredis is a glim framework extension for bringing up redis features to glim framework. It uses redis-py which is the most popular redis library for python.

Installation

  • Clone the repo
  • Move gredis folder into ext
  • Remove .git folder
# install glim-extensions from pip
pip install glim-extensions

Confguration

  • Append gredis dependancy to extensions in your config file;
  • Add the following config to the extensions config;
config = {
    'extensions' : {
        'gredis' : {
            'default' : {
                'host' : 'localhost',
                'port' : '6379',
                'db'   : 0
            }
            # add a new dict for connecting multiple redis
            # servers
        }
    },
    # ...
}

Here default is used for connection aliasing. Gredis can handle multiple connections.

Start your web server and that's it!

Usage

from glim_extensions.gredis import Redis

# performs operations in default connection
Redis.set('foo', 'bar')
Redis.set('foo', 'bar')

# performs operations in aliased connection
Redis.connection('connection-name').set('foo', 'bar')