-
Notifications
You must be signed in to change notification settings - Fork 22
Home
Introduction goes here.
from kyototycoon import KyotoTycoon
kt = KyotoTycoon()
kt.open()
kt.set('key', 'abc')
value = kt.get('key')
kt.close()
By default, python-kyototycoon connects to the localhost on port 1978 (default port of Kyoto Tycoon). Alternatively, you can choose to connect to a server of your choice when you open a new connection.
kt.open(HOSTNAME, PORT_NUMBER)
Additionally, you can choose to specify a timeout (in seconds).
kt.open(HOSTNAME, PORT_NUMBER, TIMEOUT)
By default, python-kyototycoon serializes data using the Python picke module. This means that by default, data sent over the wire / stored on Kyoto Tycoon can (generally) only be processed by Python. In order to achieve data interoperability, you can choose to use the optional JSON serializer or override the seralizer yourself. This functionality is currently in progress.
In some cases, you may know that the set of records that you’re interested is stored on a particular server/node. You may alternatively want to store a set of records on a particular node. For cases like this, you can choose to perform bulk operation and save on network round-trips and method call costs.
By default, all bulk operations in python-kyototycoon is enabled to perform operations atomically. You can choose to abandon atomicity by providing “atomic=false” as an argument to the methods but this is not recommended.
key_list = ['apple', 'banana', 'cranberry', 'durian']
r_dict = kt.get_bulk(key_list)
records = {
'apple': 'apple pie',
'banana': 'banana cake',
'cranberry': 'cranberry juice',
'durian': 'smells'
}
num_successful = kt.set_bulk(records)
key_list = ['apple', 'banana', 'cranberry', 'durian']
num_deleted = kt.remove_bulk(key_list)