Package: pygibson
Version:0.2.1pygibsonPython client forgibsoncache 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 pygibsonorgit clone https://github.com/bak1an/pygibson.git
cd pygibson
git submodule update --init
python setup.py installHow to use?frompygibsonimportClientfrompygibsonimportNotFoundErrorcl=Client()# defaults, 127.0.0.1:10128, timeout=1000cl2=Client(host="192.168.1.33",port=4321,timeout=1500)# non defaultscl3=Client(unix_socket="/var/run/gibson.sock",timeout=500)# connects to unix socket with timeout set to 500cl.set("some_key","some_value")printcl.get("some_key")# "some_value" will be printedtry:cl.get("no_such_key")exceptNotFoundError:print"Yay, no such key!"Client() class methodsMethod nameParametersDescription__init__host=”127.0.0.1”,
port=10128,
unix_socket=None,
timeout=1000Ifunix_socketis None connects tohost:port,
otherwise connects to givenunix_socket.timeoutparameter
can be used to set timeout for IO operations.
Default is 1000ms.setkey, value, ttl=0Required parameters are key and value.
Optional parameterttlcan be used to set entry TTL in seconds.
Default is 0, which means infinite TTL.msetprefix, valueSetvaluefor all keys which are starting
withprefix. This method will raiseNotFoundErrorif there are no keys
starting withprefixat server.ttlkey, ttlSet TTL in seconds forkey.mttlprefix, ttlSet TTL in seconds for all keys string withprefix.getkeyGet value for givenkey.mgetprefixGet values for keys starting withprefix.dlkeyDelete givenkeyfrom server. Renamed todlto avoid clashes with
python’s keyword.mdlprefixDelete keys starting withprefixfrom server.inckeyIncrementkeyby 1.mincprefixIncrement keys starting withprefixby 1.deckeyDecrementkeyby 1.mdecprefixDecrement keys starting withprefixby 1.lockkey, timeLockkeyfortimeseconds. Any write operations to that key will fail
andLockedErrorwill be raised.unlockkeyUnlockkey.mlockprefix, timeLock keys starting withprefixfortimeseconds.munlockprefixUnlock keys starting withprefix.countprefixGet count of keys starting withprefix.metakey, fieldGet useful info aboutkey. Allowed values forfieldare: ‘size’, ‘encoding’
‘access’, ‘created’, ‘ttl’, ‘left’, ‘lock’. Click method’s name in first column
for details ;)keysprefixGet list of keys starting withprefix.statsGet useful statistics from server. See gibson protocol docs for details.pingPing server. RaisePyGibsonErrorif failed.quitDisconnect.NOTE:values packed inbytesare returned fromget,mgetandkeysunder python 3.ExceptionsHere is a list of exceptions which are available inpygibsonmodule:ExceptionDescriptionPyGibsonErrorGeneric 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 oneNotFoundErrorNot found error. Raised when REPL_ERR_NOT_FOUND received from serverNaNErrorNot a number. Raised frominc,minc,decandmdecwhen
incrementing/decrementing not a numerical valuesNoMemoryErrorRaised when server has no free memory for your stuffLockedErrorRaised when values that you are trying to modify are lockedRoadmapConnection poolAbility to connect multiple serversBetter pypy supportLicensepygibson code is distributed under MIT license conditions, see LICENSE for
details.pygibson distribution includes bundled copy oflibgibsonclientlibrary which is written by
Simone Margaritelli and distributed on terms of BSD license.