Skip to main content

A Memcached Pool for Django

Project description

An efficient fast Django Memcached backend with a pool of connectors, based on ultramemcache.

See https://github.com/esnme/ultramemcache

Each connection added in the pool stays connected to Memcache or Membase, drastically limiting the number of reconnections and open sockets your application will use on high load.

If you configure more than one Memcache server, each new connection will randomly pick one.

Everytime a socket timeout occurs on a server, it’s blacklisted so new connections avoid picking it for a while.

To use this backend, make sure the package is installed in your environment then use memcachepool.cache.UMemcacheCache as backend in your settings.

Also, make sure you use umemcache >= 1.5

Here’s an example:

CACHES = {
    'default': {
        'BACKEND': 'memcachepool.cache.UMemcacheCache',
        'LOCATION': '127.0.0.1:11211',
        'OPTIONS': {
                'MAX_POOL_SIZE': 100,
                'BLACKLIST_TIME': 20,
                'SOCKET_TIMEOUT': 5,
                'MAX_ITEM_SIZE': 1000*100,
            }
        }
    }

Options:

  • MAX_POOL_SIZE: – The maximum number of connectors in the pool. default: 35.

  • BLACKLIST_TIME – The time in seconds a server stays in the blacklist. default: 60

  • SOCKET_TIMEOUT – the time in seconds for the socket timeout. default: 4

  • MAX_ITEM_SIZE – The maximum size for an item in Memcache.

2012-12-11 - 0.4.1

  • fixed typo

2012-12-11 - 0.4

  • added inc/decr support

  • tweaked the timeout waits

  • added and using ReconnectClient to survive servers restarts

  • added a retry loop

2012-10-05 - 0.3.1

  • fixed cache.clear

  • make sure timeout=0 is treated as infinite

2012-10-05 - 0.3

  • now based on umemcache 0.5

  • added support for MAX_ITEM_SIZE

2012-09-07 - 0.2

  • Added the licence info

2012-08-28 - 0.1

  • Initial release

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

django-memcached-pool-0.4.1.tar.gz (6.9 kB view details)

Uploaded Source

File details

Details for the file django-memcached-pool-0.4.1.tar.gz.

File metadata

File hashes

Hashes for django-memcached-pool-0.4.1.tar.gz
Algorithm Hash digest
SHA256 9e47489d1556a8e5181cb9f2c4837a378e2c6d6c4959b370f713e10fbc80e889
MD5 5105d155df589c7083a253e2835c3c42
BLAKE2b-256 85b961ef898a9422c2abeb287f32556b7bddcd21d3a4e62349184bb0641bba23

See more details on using hashes here.

Provenance

Supported by

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