Package: aiogibson
aiogibsonis a library for accessing agibsoncache database
from theasyncio(PEP-3156/tulip) framework.Gibson is a high efficiency, tree based memory cache server.
It uses a specialtriestructure allowing the
user to perform operations on multiple key sets using a prefix
expression achieving the same performance grades in the worst case,
even better on an average case then regular cache implementations
based on hash tables.Code heavily reused from awesomeaioredislibrary.GibsonPool,GibsonConnection, almost direct copy ofRedisPoolandRedisConnection, so I highly recommend to checkoutaioredis.Documentationhttp://aiogibson.readthedocs.org/InstallationMake sure that you havegibsonserver compiled and running. The easiest way
to installaiogibsonis by using the package on PyPi:pip install aiogibsonExampleimportasynciofromaiogibsonimportcreate_gibsonloop=asyncio.get_event_loop()@asyncio.coroutinedefgo():gibson=yield fromcreate_gibson('/tmp/gibson.sock',loop=loop)# set valueyield fromgibson.set(b'foo',b'bar',7)yield fromgibson.set(b'numfoo',100,7)# get valueresult=yield fromgibson.get(b'foo')print(result)# set ttl to the valueyield fromgibson.ttl(b'foo',10)# increment given keyyield fromgibson.inc(b'numfoo')# decrement given keyyield fromgibson.dec(b'numfoo')# lock key from modificationyield fromgibson.lock(b'numfoo')# unlock given keyyield fromgibson.unlock(b'numfoo')# fetch keys with given prefixyield fromgibson.keys(b'foo')# delete valueyield fromgibson.delete(b'foo')loop.run_until_complete(go())Underlying data structuretrieallows us to perform operations on multiple
key sets using a prefix expression:Multi Commandsimportasynciofromaiogibsonimportcreate_gibsonloop=asyncio.get_event_loop()@asyncio.coroutinedefgo():gibson=yield fromcreate_gibson('/tmp/gibson.sock',loop=loop)# set the value for keys verifying the given prefixyield fromgibson.mset(b'fo',b'bar',7)yield fromgibson.mset(b'numfo',100,7)# get the values for keys with given prefixresult=yield fromgibson.mget(b'fo')# set the TTL for keys verifying the given prefixyield fromgibson.mttl(b'fo',10)# increment by one keys verifying the given prefix.yield fromgibson.minc(b'numfo')# decrement by one keys verifying the given prefixyield fromgibson.mdec(b'numfoo')# lock keys with prefix from modificationyield fromgibson.mlock(b'fo')# unlock keys with given prefixyield fromgibson.munlock(b'fo')# delete keys verifying the given prefix.yield fromgibson.mdelete(b'fo')# return list of keys with given prefix ``fo``yield fromgibson.keys(b'fo')# count items for a given prefiinfo=yield fromgibson.stats()loop.run_until_complete(go())aiogibsonhas connection pooling support using context-manager:Connection Pool Exampleimportasynciofromaiogibsonimportcreate_poolloop=asyncio.get_event_loop()@asyncio.coroutinedefgo():pool=yield fromcreate_pool('/tmp/gibson.sock',minsize=5,maxsize=10,loop=loop)# using context managerwith(yield frompool)asgibson:yield fromgibson.set('foo','bar')value=yield fromgibson.get('foo')print(value)# NOTE: experimental feature# or without context manageryield frompool.set('foo','bar')resp=yield frompool.get('foo')yield frompool.delete('foo')pool.clear()loop.run_until_complete(go())Also you can have simple low-level interface togibsonserver:Low Level Commandsimportasynciofromaiogibsonimportcreate_gibsonloop=asyncio.get_event_loop()@asyncio.coroutinedefgo():gibson=yield fromcreate_connection('/tmp/gibson.sock',loop=loop)# set valueyield fromgibson.execute(b'set',b'foo',b'bar',7)# get valueresult=yield fromgibson.execute(b'get',b'foo')print(result)# delete valueyield fromgibson.execute(b'del',b'foo')loop.run_until_complete(go())RequirementsPython3.3+asyncioorPython3.4+LicenseTheaiogibsonis offered under MIT license.Changes0.1.3 (2015-02-10)Documentation published onhttp://aiogibson.readthedocs.org/:Added wait closed finalizer;Improved test coverage to 99%;Fixed bug with canceled future;Added limit argument to mget command;0.1.2 (2014-10-15)Changed Reader interface to be similar to hiredis;Most methods from high level interface now return Future;Connection pool, works as drop in replacement for high level connection;Added more docstrings;0.1.1 (2014-09-06)Improved protocol parser;Added type checking in high-level commands;Added check for None arguments in connection execute command;0.1.0 (2014-08-17)Initial release;