Skip to main content

Python client for SSDB

Project description

The Python interface to the SSDB like Redis-py

Installation

To install ssdb-py, simply:

$ sudo pip install ssdb

or alternatively (you really should be using pip though):

$ sudo easy_install ssdb

or from source:

$ sudo python setup.py install

Getting Started

>>> from ssdb import SSDB
>>> ssdb = SSDB(host='localhost', port=8888)
>>> ssdb.multi_set(set_a='a', set_b='b', set_c='c', set_d='d')
4
>>> ssdb.multi_set(set_x1='x1', set_x2='x2', set_x3='x3', set_x4='x4')
4
>>> ssdb.multi_set(set_abc='abc', set_count=10)
2
>>> ssdb.multi_hset('hash_1', a='A', b='B', c='C', d='D', e='E', f='F',
...                 g='G')
7
>>> ssdb.multi_hset('hash_2',
...                 key1=42,
...                 key2=3.1415926,
...                 key3=-1.41421,
...                 key4=256,
...                 key5='e',
...                 key6='log'
...                )
6
>>> ssdb.multi_zset('zset_1', a=30, b=20, c=100, d=1, e=64, f=-3,
...                 g=0)
7
>>> ssdb.multi_zset('zset_2',
...                 key1=42,
...                 key2=314,
...                 key3=1,
...                 key4=256,
...                 key5=0,
...                 key6=-5
...                )
6
>>> ssdb.get('set_a')
'a'
>>> ssdb.setx('set_ttl', 'ttl', 5)
True
>>> ssdb.get('set_ttl')
'ttl'
>>> time.sleep(5)
>>> ssdb.get('set_ttl')
>>>
>>> ssdb.exists('set_a')
True
>>> ssdb.incr('set_count', 3)
13
>>> ssdb.multi_get('a', 'b', 'c', 'd')
{'a': 'a', 'c': 'c', 'b': 'b', 'd': 'd'}
>>> ssdb.keys('set_x ', 'set_xx', 3)
['set_x1', 'set_x2', 'set_x3']
>>> ssdb.scan('set_x ', '', 10)
{'set_x1': 'x1', 'set_x2': 'x2', 'set_x3': 'x3', 'set_x4': 'x4'}
>>> ssdb.delete('set_abc')
True
>>> ssdb.hget("hash_1", 'a')
'A'
>>> ssdb.hexists('hash_2', 'key2')
True
>>> ssdb.hdecr('hash_2', 'key1', 7)
36
>>> ssdb.hsize('hash_1')
7
>>> ssdb.hlist('hash_ ', 'hash_z', 10)
['hash_1', 'hash_2']
>>> ssdb.hscan('hash_1', 'a', 'g', 10)
{'b': 'B', 'c': 'C', 'd': 'D', 'e': 'E', 'f': 'F', 'g': 'G'}
>>> ssdb.zget("zset_1", 'b')
20
>>> ssdb.zset("zset_1", 'z', 1024)
True
>>> ssdb.zset_exists('zset_2')
True
>>> ssdb.multi_zget('zset_1', 'a', 'b', 'c', 'd')
{'a': 30, 'c': 100, 'b': 20, 'd': 1}
>>> ssdb.zkeys('zset_1', '', 0, 200, 3)
['g', 'd', 'b']
>>> ssdb.zscan('zset_1', '', 0, 200, 10)
{'g': 0, 'd': 1, 'b': 20, 'a': 30, 'e': 64, 'c': 100}
>>> ssdb.zrscan('zset_1', 'a', 30, -1000, 3)
{'b': 20, 'd': 1, 'g': 0}
>>> ssdb.zrank('zset_1','d')
2
>>> ssdb.zrrange('zset_1', 0, 4)
{'c': 100, 'e': 64, 'a': 30, 'b': 20}

Project details


Download files

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

Source Distribution

ssdb-0.0.3.tar.gz (23.9 kB view details)

Uploaded Source

File details

Details for the file ssdb-0.0.3.tar.gz.

File metadata

  • Download URL: ssdb-0.0.3.tar.gz
  • Upload date:
  • Size: 23.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for ssdb-0.0.3.tar.gz
Algorithm Hash digest
SHA256 12e618fe0ca1cca558d8a8644f4c6dc97b03d607105ae335d0680a5114ba8944
MD5 c25daf5fb5b16fd3328fe66ca1eb1a30
BLAKE2b-256 1880835470a529a7c069af367349a074c474c35151879b3ab5d2ca2d9ebe2f7b

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page