forked from moonpolysoft/dynomite
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.py
39 lines (27 loc) · 884 Bytes
/
test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import sys
sys.path.append("gen-py")
from dynomite import Dynomite
from dynomite.ttypes import *
from thrift import Thrift
from thrift.transport import TSocket
from thrift.transport import TTransport
from thrift.protocol import TBinaryProtocol
# Make socket
transport = TSocket.TSocket('localhost', 9200)
# Buffering is critical. Raw sockets are very slow
transport = TTransport.TBufferedTransport(transport)
# Wrap in a protocol
protocol = TBinaryProtocol.TBinaryProtocol(transport)
client = Dynomite.Client(protocol)
transport.open()
print client.put("b", None, "b value")
rb = client.get("b")
client.put("b", rb.context, "electric b-value monkey fish!")
r = client.get("a")
print r
print client.put("a", r.context, "a new value")
print client.get("a")
print client.put("a", r.context, "a newer new value")
print client.get("a")
print client.get("b")
transport.close()