Skip to main content

memcache session

Project description

Session Data Using memcache

This package provides a session data manager which stores it’s data in memcache. The package uses lovely.memcached to store it’s data.

IMPORTANT:

This test expects a memcache server running on local port 11211 which is the default port for memcached.

This test runs in level 2 because it needs external resources to work. If you want to run this test you need to use –all as parameter to your test.

Start a memcache instance with : memcached <optional options>

>>> from zope import component
>>> from lovely.memcached.interfaces import IMemcachedClient
>>> from lovely.memcached.utility import MemcachedClient
>>> util = MemcachedClient()
>>> component.provideUtility(util, IMemcachedClient, name='session')
>>> util.invalidateAll()

Now we create a memcache session and connect it to the memcached client.

>>> from lovely.session.memcached import MemCachedSessionDataContainer
>>> sessionData = MemCachedSessionDataContainer()
>>> sessionData.cacheName = u'session'

We need to provide a name for the session data manager because it is used to identify the cache entry in memcache.

>>> sessionData.__name__ = 'MemCacheSession'
>>> session = sessionData['mySessionId']
>>> session
{}
>>> type(session)
<class 'lovely.session.memcached.MemCacheSessionData'>

We can now get data from the session.

>>> data = session['myData']
>>> data
{}
>>> type(data)
<class 'lovely.session.memcached.MemCachePkgData'>
>>> data['info'] = 'stored in memcache'
>>> data
{'info': 'stored in memcache'}

Because the MemCacheSession is transaction aware we need to commit the transaction to store data in the memcache.

>>> import transaction
>>> transaction.commit()

If we now read session data is is read back from the memcache.

>>> session = sessionData['mySessionId']
>>> session['myData']
{'info': 'stored in memcache'}
>>> sessionData.items()
[('mySessionId', <lovely.session.memcached.DataManager object at ...>)]

lovely.session

2007/08/13 0.1.2

  • move source to zope.org

2007/08/13 0.1.1

  • fixed dependency on lovely.memcached

Download

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

lovely.session-0.1.2.tar.gz (6.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

lovely.session-0.1.2-py2.4.egg (12.9 kB view details)

Uploaded Egg

File details

Details for the file lovely.session-0.1.2.tar.gz.

File metadata

File hashes

Hashes for lovely.session-0.1.2.tar.gz
Algorithm Hash digest
SHA256 5c651ed89d377ab7c43e0cd0e1ae9e59de0c5910abb0465b9b4f5a79cd9b8d57
MD5 bed6f42446d6cbd9831cfcefb51f5d72
BLAKE2b-256 b2ec9efe782da53c62227e820d1feec06dea1f33c708686f903f3ada1670bb96

See more details on using hashes here.

File details

Details for the file lovely.session-0.1.2-py2.4.egg.

File metadata

File hashes

Hashes for lovely.session-0.1.2-py2.4.egg
Algorithm Hash digest
SHA256 eb92b6b2808b8c916861b4df40d5ab86058aba995081733ffb8c1b6e5692bd15
MD5 f67d417f7f19a63afe80ec280164cdfb
BLAKE2b-256 5808474ab056613d0a60bfe0072b329bbc96906207167877874abf695879310b

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page