1 module redis.commands.list; 2 3 mixin template listCommands() 4 { 5 /* 6 * Set the value of an element in a list by its index. 7 * @return 8 */ 9 bool lset(string key,int index,string value) 10 { 11 auto result = send!(bool)("LSET",key,index,value); 12 return result; 13 } 14 15 /* 16 * Prepend one or multiple values to a list. 17 * @return 18 */ 19 int lpush(T...)(string key,string args) 20 { 21 auto result = send!(int)("LPUSH",key,args); 22 return result; 23 } 24 25 /* 26 * Remove and get the first element in a list. 27 * @return 28 */ 29 string lpop(string key) 30 { 31 auto result = send!(string)("LPOP",key); 32 return result; 33 } 34 35 /* 36 * Get a range of elements from a list. 37 * @return 38 */ 39 string[] lrange(string key,int start,int end) 40 { 41 auto result = send("lrange",key,start,end); 42 return result.toStringArray; 43 } 44 45 46 /* 47 * Get the length of a list. 48 * @return 49 */ 50 int llen(string key) 51 { 52 auto result = send!(int)("LLEN",key); 53 return result; 54 } 55 }