Giter VIP home page Giter VIP logo

cherrys's Introduction

Cherrys : a Redis backend for CherryPy sessions

CherryPy kicks some serious arse in the 'I am just a HTTP framework' category! As of version 3.2 it supports 4 types of storage for sessions by default:

Redis is growing in popularity as an alternative to Memcached (and is fully supported on dotCloud!)

Installation

If you are not using pip yet. Install it and while you are at it consider using virtualenv too.

$ pip install cherrys

redis-py and CherryPy are required dependencies hence will be installed if necessary.

We recommend installing hiredis-py (a faster parser) as well.

$ pip install hiredis

Usage (and abusage)

To tell CherryPy which backend to use, we need to specify the storage_type for the sessions tool. You may want to read more about CherryPy configuration.

tools.sessions.storage_type : 'redis'

But CherryPy doesn't know Redis. Hence the first thing we need to do is add the cherrys RedisSession class to cherrypy.lib.sessions.

import cherrys
cherrypy.lib.sessions.RedisSession = cherrys.RedisSession

It is that simple!

Config dictionary

There are 4 optional parameters you can set:

  • host [127.0.0.1]
  • port [6379]
  • db [0]
  • password [None]

A full config dictionary to activate Redis backed sessions would look like this.

config = {
    'tools.sessions.on' : True,
    'tools.sessions.storage_type' : 'redis',
    'tools.sessions.host' : 'REDIS_HOST',
    'tools.sessions.port' : REDIS_PORT,
    'tools.sessions.db' : REDIS_DB,
    'tools.sessions.password' : 'REDIS_PASSWORD'
    }

cherrys's People

Contributors

3kwa 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.