author | Alberto Bertogli
<albertito@gmail.com> 2007-04-29 06:55:34 UTC |
committer | Alberto Bertogli
<albertito@gmail.com> 2007-04-29 06:55:34 UTC |
parent | 317141da26c3ee992807dccf06ae503d7fad4379 |
doc/design.rst | +3 | -0 |
doc/guide.rst | +4 | -3 |
doc/network.rst | +9 | -3 |
diff --git a/doc/design.rst b/doc/design.rst index 2acb447..a63120c 100644 --- a/doc/design.rst +++ b/doc/design.rst @@ -62,6 +62,9 @@ cache_set *key* *value* cache_del *key* Like *del*, but only affects the cache and not the database. +cache_cas *key* *oldvalue* *newvalue* + Do a compare-and-swap, using *oldvalue* to compare with the value stored in + the database, and replacing it with *newvalue* if they match. As you can see, it's possible to operate exclusively with the cache, ignoring the database completely. This is very similar to what memcached_ does. Note diff --git a/doc/guide.rst b/doc/guide.rst index f0de916..7ee5a60 100644 --- a/doc/guide.rst +++ b/doc/guide.rst @@ -214,9 +214,10 @@ Thread safety that needs it. Available operations - You can request the server to do three operations: *set* a value to a key, - *get* the value associated with the given key, and *delete* a given key - (with its associated value). + You can request the server to do four operations: *set* a value to a key, + *get* the value associated with the given key, *delete* a given key (with + its associated value), and perform a *compare-and-swap* of the values + associated with the given key. Request modes For each operation, you will have three different modes available: diff --git a/doc/network.rst b/doc/network.rst index 78b26a1..65b8249 100644 --- a/doc/network.rst +++ b/doc/network.rst @@ -51,6 +51,8 @@ REQ_SET_SYNC 0x105 REQ_DEL_SYNC 0x106 REQ_SET_ASYNC 0x107 REQ_DEL_ASYNC 0x108 +REQ_CACHE_CAS 0x109 +REQ__CAS 0x110 ============== ====== @@ -67,6 +69,9 @@ REQ_SET_* and REQ_CACHE_SET REQ_DEL_* and REQ_CACHE_DEL You guessed it, they share the payload format too: first the key size (32 bits), and then the key. +REQ_CAS and REQ_CACHE_CAS + First the key size, then the old value size, then the new value size, and + then the key, the old value and the new value. Replies @@ -107,6 +112,7 @@ REP_CACHE_HIT 0x801 REP_CACHE_MISS 0x802 REP_OK 0x803 REP_NOTIN 0x804 +REP_NOMATCH 0x805 ================ ====== @@ -115,14 +121,14 @@ Reply payload formats REP_ERR The payload is a 32-bit error code, according to the table below. -REP_CACHE_MISS and REP_NOTIN +REP_CACHE_MISS, REP_NOTIN and REP_NOMATCH These replies have no payload. REP_CACHE_HIT The first 32 bits are the value size, then the value. REP_OK Depending on the request, this reply does or doesn't have an associated - value. For *REQ_SET** or *REQ_DEL** there is no payload. But for *REQ_GET* - the first 32 bits are the value size, and then the value. + value. For *REQ_SET**, *REQ_DEL** and *REQ_CAS** there is no payload. But + for *REQ_GET* the first 32 bits are the value size, and then the value. Reply error codes