This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (
Help us improve Python packaging - Donate today!

Python client for gibson cache server

Project Description


Python client for gibson cache server.

Which python versions are supported?

Currently testsuite runs with python 2.6, 2.7, 3.2 and 3.3.

All tests are passing successfully with PyPy 2.0.2 but since pygibson is implemented as CPython extension it’s not recommended to use it with PyPy. We need to find some workaround to this later.

How to install?

pip install pygibson


git clone
cd pygibson
git submodule update --init
python install

How to use?

from pygibson import Client
from pygibson import NotFoundError

cl = Client() # defaults,, timeout=1000
cl2 = Client(host="", port=4321, timeout=1500) # non defaults
cl3 = Client(unix_socket="/var/run/gibson.sock", timeout=500) # connects to unix socket with timeout set to 500

cl.set("some_key", "some_value")
print cl.get("some_key")  # "some_value" will be printed
except NotFoundError:
    print "Yay, no such key!"

Client() class methods

Method name Parameters Description
__init__ host=””, port=10128, unix_socket=None, timeout=1000 If unix_socket is None connects to host:port, otherwise connects to given unix_socket. timeout parameter can be used to set timeout for IO operations. Default is 1000ms.
set key, value, ttl=0 Required parameters are key and value. Optional parameter ttl can be used to set entry TTL in seconds. Default is 0, which means infinite TTL.
mset prefix, value Set value for all keys which are starting with prefix. This method will raise NotFoundError if there are no keys starting with prefix at server.
ttl key, ttl Set TTL in seconds for key.
mttl prefix, ttl Set TTL in seconds for all keys string with prefix.
get key Get value for given key.
mget prefix Get values for keys starting with prefix.
dl key Delete given key from server. Renamed to dl to avoid clashes with python’s keyword.
mdl prefix Delete keys starting with prefix from server.
inc key Increment key by 1.
minc prefix Increment keys starting with prefix by 1.
dec key Decrement key by 1.
mdec prefix Decrement keys starting with prefix by 1.
lock key, time Lock key for time seconds. Any write operations to that key will fail and LockedError will be raised.
unlock key Unlock key.
mlock prefix, time Lock keys starting with prefix for time seconds.
munlock prefix Unlock keys starting with prefix.
count prefix Get count of keys starting with prefix.
meta key, field Get useful info about key. Allowed values for field are: ‘size’, ‘encoding’ ‘access’, ‘created’, ‘ttl’, ‘left’, ‘lock’. Click method’s name in first column for details ;)
keys prefix Get list of keys starting with prefix.
stats   Get useful statistics from server. See gibson protocol docs for details.
ping   Ping server. Raise PyGibsonError if failed.
quit   Disconnect.
NOTE:values packed in bytes are returned from get, mget and keys under python 3.


Here is a list of exceptions which are available in pygibson module:

Exception Description
PyGibsonError Generic error. raised when REPL_ERR received from server or any other error occurred (connection refused, timeout, etc). All other pygibson exceptions are subclassed from this one
NotFoundError Not found error. Raised when REPL_ERR_NOT_FOUND received from server
NaNError Not a number. Raised from inc, minc, dec and mdec when incrementing/decrementing not a numerical values
NoMemoryError Raised when server has no free memory for your stuff
LockedError Raised when values that you are trying to modify are locked


  • Connection pool
  • Ability to connect multiple servers
  • Better pypy support


pygibson code is distributed under MIT license conditions, see LICENSE for details.

pygibson distribution includes bundled copy of libgibsonclient library which is written by Simone Margaritelli and distributed on terms of BSD license.

Release History

Release History

This version
History Node


History Node


History Node


Download Files

Download Files

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

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
pygibson-0.2.1.tar.gz (19.8 kB) Copy SHA256 Checksum SHA256 Source Aug 2, 2015

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting