This is a pre-production deployment of Warehouse, however changes made here WILL affect the production instance of PyPI.
Latest Version Dependencies status unknown Test status unknown Test coverage unknown
Project Description

aiogibson is a library for accessing a gibson cache database from the asyncio (PEP-3156/tulip) framework.

Gibson is a high efficiency, tree based memory cache server. It uses a special trie structure 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 awesome aioredis library. GibsonPool, GibsonConnection, almost direct copy of RedisPool and RedisConnection, so I highly recommend to checkout aioredis.

Installation

Make sure that you have gibson server compiled and running. The easiest way to install aiogibson is by using the package on PyPi:

pip install aiogibson

Example

import asyncio
from aiogibson import create_gibson

loop = asyncio.get_event_loop()


@asyncio.coroutine
def go():
    gibson = yield from create_gibson('/tmp/gibson.sock', loop=loop)
    # set value
    yield from gibson.set(b'foo', b'bar', 7)
    yield from gibson.set(b'numfoo', 100, 7)

    # get value
    result = yield from gibson.get(b'foo')
    print(result)

    # set ttl to the value
    yield from gibson.ttl(b'foo', 10)

    # increment given key
    yield from gibson.inc(b'numfoo')

    # decrement given key
    yield from gibson.dec(b'numfoo')

    # lock key from modification
    yield from gibson.lock(b'numfoo')

    # unlock given key
    yield from gibson.unlock(b'numfoo')

    # fetch keys with given prefix
    yield from gibson.keys(b'foo')

    # delete value
    yield from gibson.delete(b'foo')


loop.run_until_complete(go())

Underlying data structure trie allows us to perform operations on multiple key sets using a prefix expression:

Multi Commands

import asyncio
from aiogibson import create_gibson

loop = asyncio.get_event_loop()


@asyncio.coroutine
def go():
    gibson = yield from create_gibson('/tmp/gibson.sock', loop=loop)

    # set the value for keys verifying the given prefix
    yield from gibson.mset(b'fo', b'bar', 7)
    yield from gibson.mset(b'numfo', 100, 7)

    # get the values for keys with given prefix
    result = yield from gibson.mget(b'fo')

    # set the TTL for keys verifying the given prefix
    yield from gibson.mttl(b'fo', 10)

    # increment by one keys verifying the given prefix.
    yield from gibson.minc(b'numfo')

    # decrement by one keys verifying the given prefix
    yield from gibson.mdec(b'numfoo')

    # lock keys with prefix from modification
    yield from gibson.mlock(b'fo')

    # unlock keys with given prefix
    yield from gibson.munlock(b'fo')

    # delete keys verifying the given prefix.
    yield from gibson.mdelete(b'fo')

    # return list of keys with given prefix ``fo``
    yield from gibson.keys(b'fo')

    # count items for a given prefi
    info = yield from gibson.stats()


loop.run_until_complete(go())

aiogibson has connection pooling support using context-manager:

Connection Pool Example

import asyncio
from aiogibson import create_pool

loop = asyncio.get_event_loop()

@asyncio.coroutine
def go():
    pool = yield from create_pool('/tmp/gibson.sock', minsize=5, maxsize=10,
                                  loop=loop)
    # using context manager
    with (yield from pool) as gibson:
        yield from gibson.set('foo', 'bar')
        value = yield from gibson.get('foo')
        print(value)

    # NOTE: experimental feature
    # or without context manager
    yield from pool.set('foo', 'bar')
    resp = yield from pool.get('foo')
    yield from pool.delete('foo')

    pool.clear()

loop.run_until_complete(go())

Also you can have simple low-level interface to gibson server:

Low Level Commands

import asyncio
from aiogibson import create_gibson

loop = asyncio.get_event_loop()


@asyncio.coroutine
def go():
    gibson = yield from create_connection('/tmp/gibson.sock', loop=loop)

    # set value
    yield from gibson.execute(b'set', b'foo', b'bar', 7)

    # get value
    result = yield from gibson.execute(b'get', b'foo')
    print(result)
    # delete value
    yield from gibson.execute(b'del', b'foo')


loop.run_until_complete(go())

Requirements

License

The aiogibson is offered under MIT license.

Changes

0.1.3 (2015-02-10)

  • Documentation published on http://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;
Release History

Release History

0.1.3

This version

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.1.2

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.1.1

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.1.0

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

Download Files

Download Files

TODO: Brief introduction on what you do with files - including link to relevant help section.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
aiogibson-0.1.3.tar.gz (14.2 kB) Copy SHA256 Checksum SHA256 Source Feb 10, 2015

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS HPE HPE Development 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