1 module redis.commands..string; 2 3 mixin template stringCommands() 4 { 5 /* 6 * Set key to hold the string value. If key already holds a value, it is overwritten 7 * @return 8 */ 9 bool set(string key,string value) 10 { 11 import std.stdio;writeln(__FUNCTION__,"\t",key,"\t",value); 12 auto result = send!(bool)("SET",key,value); 13 return result; 14 } 15 bool set(string key,string value,int timeout) 16 { 17 auto result = send!(bool)("SET",key,value,"EX",timeout); 18 return result; 19 } 20 bool set(string key,string value,string flag) 21 { 22 auto result = send!(bool)("SET",key,value,flag); 23 return result; 24 } 25 bool set(string key,string value,string flag,int timeout) 26 { 27 auto result = send!(bool)("SET",key,value,flag,"EX",timeout); 28 return result; 29 } 30 31 /* 32 * Increments the number stored at key by one. 33 * @return 34 */ 35 int incr(string key) 36 { 37 auto result = send!(int)("INCR",key); 38 return result; 39 } 40 41 /* 42 * Get the value of key. 43 * @return 44 */ 45 string get(string key) 46 { 47 auto result = send!(string)("GET",key); 48 return result; 49 } 50 51 /* 52 * If key already exists and is a string, this command appends the value at the end of the string. 53 * If key does not exist it is created and set as an empty string. 54 * @return 55 */ 56 string append(string key,string value) 57 { 58 auto result = send!(string)("APPEND",key,value); 59 return result; 60 } 61 62 }