tango.net.util.MemCache

License:

BSD style: see license.txt

Version:

Mar 2005: Initial release

Author:

Kris
class MemCache : private Thread #
this(char[][] hosts, uint watchdog = 3) #
void close() [final] #
bool set(void[] key, void[] value, int flags = 0, int timeout = 0) [final] #
Store the key and value
bool add(void[] key, void[] value, int flags = 0, int timeout = 0) [final] #
Store the value if key does not already exist
bool replace(void[] key, void[] value, int flags = 0, int timeout = 0) [final] #
Store the value only if key exists
bool remove(void[] key, int timeout = 0) [final] #
Remove the specified key and make key "invalid" for the duration of timeout, causing add(), get() and remove() on the same key to fail within that period
bool get(void[] key, Buffer buffer) [final] #
VALUE \r\n \r\n
bool incr(void[] key, uint value) [final] #
bool decr(void[] key, uint value) [final] #
bool incr(void[] key, uint value, ref uint result) [final] #
bool decr(void[] key, uint value, ref uint result) [final] #
void status(void delegate (char[], char[][] list) dg) [final] #
Buffer buffer(uint size) [final] #
void setHosts(char[][] hosts) [final] #
void run() [private] #
Connection watchdog thread
Connection select(void[] key) [private] #
void connect(Connection[] hosts) [private] #
class Buffer [static] #
this(uint size) [private] #
bool expand(uint size) #
void[] set(uint size) #
void[] get() #
uint jhash(void[] x, uint c = 0) [static, final] #
jhash() -- hash a variable-length key into a 32-bit value k : the key (the unaligned variable-length array of bytes) len : the length of the key, counting by bytes level : can be any 4-byte value Returns a 32-bit value. Every bit of the key affects every bit of the return value. Every 1-bit and 2-bit delta achieves avalanche. About 4.3*len + 80 X86 instructions, with excellent pipelining The best hash table sizes are powers of 2. There is no need to do mod a prime (mod is sooo slow!). If you need less than 32 bits, use a bitmask. For example, if you need only 10 bits, do h = (h & hashmask(10)); In which case, the hash table should have hashsize(10) elements. If you are hashing n strings (ub1 **)k, do it like this: for (i=0, h=0; i<n; ++i) h = hash( k[i], len[i], h); By Bob Jenkins, 1996. bob_jenkins@burtleburtle.net. You may use this code any way you wish, private, educational, or commercial. It's free. See http://burlteburtle.net/bob/hash/evahash.html Use for hash table lookup, or anything where one collision in 2^32 is acceptable. Do NOT use for cryptographic purposes.
class Connection [private] #
this(char[] host) #
void connect() [private] #
void close() [private, synchronized] #
void error() [private] #
bool put(char[] cmd, void[] key, void[] value, int flags, int timeout) [private, synchronized] #
bool get(void[] key, MemCache.Buffer buffer) [private, synchronized] #
VALUE \r\n \r\n
bool remove(void[] key, int timeout = 0) [private, synchronized] #
Remove the specified key and make key "invalid" for the duration of timeout, causing add(), get() and remove() on the same key to fail within that period
bool bump(char[] cmd, void[] key, uint value, ref uint result) [private, synchronized] #
void status(void delegate (char[], char[][] list) dg) [private, synchronized] #