Ejemplo n.º 1
0
 def close(self):
     return HDB.close(self)
Ejemplo n.º 2
0
#!/usr/bin/python
#
#  This code is based upon example.pl from the Perl TokyoCabinet API.
#

import sys

from pytc import HDB, HDBOWRITER, HDBOCREAT
hdb = HDB()
# Open a hashdb for writing if it exists, or create a new one
# This database is uncompressed. See hashdb.create for example of compression.
hdb.open("casket.tch", HDBOWRITER | HDBOCREAT)

# store records
hdb.put("foo", "hop")
hdb.put("bar", "step")
hdb.put("baz", "jump")

# retrieve records
print hdb.get("foo")

# traverse records
hdb.iterinit()
for key in hdb.keys():
    print "%s:%s" % (key, hdb.get(key))

# close the database
hdb.close()
Ejemplo n.º 3
0
 def put(self, key, value):
     return HDB.put(self, key, common.json.dumps(value))
Ejemplo n.º 4
0
 def values(self):
     return [common.json.loads(v) for v in HDB.values(self)]
Ejemplo n.º 5
0
 def __setitem__(self, key, value):
     return HDB.__setitem__(self, key, common.json.dumps(value))
Ejemplo n.º 6
0
 def get(self, key):
     return common.json.loads(HDB.get(self, key))
Ejemplo n.º 7
0
 def close(self):
     return HDB.close(self)
Ejemplo n.º 8
0
 def __getitem__(self, key):
     return common.json.loads(HDB.__getitem__(self, key))
Ejemplo n.º 9
0
 def values(self):
     return [common.json.loads(v) for v in HDB.values(self)]
Ejemplo n.º 10
0
 def put(self, key, value):
     return HDB.put(self, key, common.json.dumps(value))
Ejemplo n.º 11
0
 def get(self, key):
     return common.json.loads(HDB.get(self, key))
Ejemplo n.º 12
0
 def __setitem__(self, key, value):
     return HDB.__setitem__(self, key, common.json.dumps(value))
Ejemplo n.º 13
0
 def __getitem__(self, key):
     return common.json.loads(HDB.__getitem__(self, key))