finchan.interface.kvstore

kvstore Interface, inspired by redis-py.

AbsKvStore

class finchan.interface.kvstore.AbsKvStore(*args, **kwargs)[source]

KV store interface

init the kvstore connection

set(name, value)[source]

Set the value at key name to value.

get(name)[source]

Return the value at key name, or None if the key doesn’t exist.

mset(*args, **kwargs)[source]

Sets key/values based on a mapping. Mapping can be supplied as a single dictionary argument or as kwargs.

mget(keys, *args)[source]

Returns a list of values ordered identically to keys.

setnx(name, value)[source]

Set the value of key name to value if key doesn’t exist.

delete(name)[source]

Delete the key and its value.

hset(name, key, value)[source]

Set key to value within hash name.

Returns 1 if HSET created a new field, otherwise 0.

hget(name, key)[source]

Return the value of key within the hash name.

hmset(name, mapping)[source]

Set key to value within hash name for each corresponding key and value from the mapping dict.

hmget(name, keys, *args)[source]

Returns a list of values ordered identically to keys.

hgetall(name)[source]

Return a Python dict of the hash’s name/value pairs.

hsetnx(name, key, value)[source]

Set key to value within hash name if key does not exist.

Returns 1 if HSETNX created a field, otherwise 0.

hdel(name, *keys)[source]

Delete keys from hash name.

hexists(name, key)[source]

Returns a boolean indicating if key exists within hash name.

hkeys(name)[source]

Return the list of keys within hash name.

hvals(name)[source]

Return the list of values within hash name.

hlen(name)[source]

Return the number of elements in hash name.

lpop(name)[source]

Remove and return the first item of the list name.

lpush(name, value)[source]

Push values onto the head of the list name.

rpop(name)[source]

Remove and return the last item of the list name.

rpush(name, *value)[source]

Push values onto the tail of the list name.

lset(name, index, value)[source]

Set position of list name to value.

lrange(name, start, end)[source]

Return a slice of the list name between position start and end.

start and end can be negative numbers just like Python slicing notation.

ltrim(name, start, end)[source]

Trim the list name, removing all values not within the slice between start and end.

start and end can be negative numbers just like Python slicing notation.

llen(name)[source]

Return the length of the list name