forked from scalien/keyspace
-
Notifications
You must be signed in to change notification settings - Fork 1
/
API
107 lines (78 loc) · 3.37 KB
/
API
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
Contact
=======
If you are experiencing difficulties please visit our Google Groups page:
- group home page: http://groups.google.com/group/keyspace
- group email address: keyspace@googlegroups.com
The official Keyspace homepage is at http://scalien.com
For complete API reference, see:
http://scalien.com/documentation
Keyspace Client Application Programming Interface (API)
=======================================================
It is a good idea to have a basic understanding of your
distributed system. Thus it is recommended that you read the
Keyspace whitepaper first. The whitepaper is at
http://scalien.com/whitepapers
Keyspace is a *master based* replicated database, where
certain operations are only serviced by the master node.
These operations are
- write operations
(SET, TEST-AND-SET, ADD, DELETE, REMOVE, PRUNE and SUBMIT)
- safe read operations
(GET, LIST-KEYS, LIST-KEYVALUES, COUNT)
The following operations are served by *all* nodes:
- who is the current master
(GET-MASTER)
- dirty read operations
(DIRTY-GET, DIRTY-LIST-KEYS, DIRTY-LIST-KEYVALUES, DIRTY-COUNT)
Dirty read operations will succeed on any server regardless of
internode connectivity, but may return inconsistent (not up-to-date)
data; hence the name dirty.
If your client wants to modify the database, it must be connected
to the master. On the other hand, if consistency does not matter
or your application logic guarantees it (eg. you stopped all writers),
you can connect to any node and perform dirty reads.
HTTP protocol
=============
You can issue all commands over HTTP with the GET method. The commands
and responses are people-friendly, so you can issue them from your browser.
Be aware that HTTP should only be used for testing and peeking, as each
command creates a new TCP/HTTP connection, which is fairly expensive and
unnecessary. The programmatic APIs use the Keyspace protocol.
The syntax for HTTP commands is http://yoursever:port
where port is http.port specified in your conf file (default 8080).
If you look at the root http://yoursever:port Keyspace displays
its version number and master information.
The commands are:
/html/listkeys?prefix,startkey,count,next,forward
/html/listkeyvalues?prefix,startkey,count,next,forward
/html/dirtylistkeys?prefix,startkey,count,next,forward
/html/dirtylistkeyvalues?prefix,startkey,count,next,forward
and
/getmaster
/get?key
/dirtyget?key
/set?key,value
/testandset?key,test,value
/add?key,num
/rename?key,newKey
/delete?key
/remove?key
/prune?prefix
/listkeys?prefix,startkey,count,next,forward
/listkeyvalues?prefix,startkey,count,next,forward
/count?prefix,startkey,count,next,forward
/dirtylistkeys?prefix,startkey,count,next,forward
/dirtylistkeyvalues?prefix,startkey,count,next,forward
/dirtycount?prefix,startkey,count,next,forward
The commands starting with /html/ produce pretty-printed lists where the keys
are clickable links to the appropriate GET command.
For the list and count commands:
- the list returns keys starting with <prefix>
- listing starts with <prefix> + <startkey> (<startkey> is optional)
- return at most <count> elements (<count> is optional)
- if <next> is x, the first x elements are skipped (<next> is optional)
- if <forward> is not 'f', list backwards (<forward> is optional)
Other protocols
===============
There are client libraries in other langauges, for complete reference, see:
http://scalien.com/documentation