R&D/NoSQL

Aerospike Python client

sunshout 2015. 7. 28. 18:55

send key in protocol


put policy has various options


put(keybins[meta[policy[serializer]]])

Write a record with a given key to the cluster.

Parameters:
  • key (tuple) – a Key Tuple tuple associated with the record.
  • bins (dict) – a dict of bin-name / bin-value pairs.
  • meta (dict) – optional record metadata to be set, with field 'ttl' set to int number of seconds.
  • policy (dict) – optional Write Policies.
  • serializer – optionally override the serialization mode of the client with one of the Serialization Constants.
Raises:

a subclass of AerospikeError.


Write Policies

policy

dict of optional write policies which are applicable to put(). See Policies.


import aerospike

import time

config = {

    'hosts': [('192.168.1.1',3000)],

    'policies' : {'timeout':10000}

}

client = aerospike.client(config)

client.connect()


# key = (namespace, set, key)

key = ("test","demo123","foo")

rec = {

    'uid': 'choonho',

    'name': 'Son Choonho',

    'dob': '19xx',

    'avator': 'http://www.xxx.xxx',

    'points': 167

}


print "connecting ...:", client

print "start put"

print client.put(key, rec, policy={'key':aerospike.POLICY_KEY_SEND})