mooncached.lua

changeset 13
db66a09dc0b6
parent 12
fb941ed514c6
child 17
5bede08f2f55
equal deleted inserted replaced
12:fb941ed514c6 13:db66a09dc0b6
82 end 82 end
83 conn:write("END\r\n"); 83 conn:write("END\r\n");
84 return true; 84 return true;
85 end 85 end
86 86
87 function command_handlers.delete(conn, params)
88 local key, keyend = params:match("^(%S+)()");
89 local time, reply = params:match(" (%d+)", keyend), params:match(" (noreply)$", keyend);
90 time, reply = tonumber(time), reply ~= "noreply";
91 local ok, err;
92 if not key then
93 ok, err = false, "Unable to determine key from request";
94 else
95 ok, err = cache:delete(key, time);
96 if ok then
97 if err then
98 conn:write("DELETED\r\n");
99 else
100 conn:write("NOT_FOUND\r\n");
101 end
102 end
103 end
104 if not reply then
105 return nil;
106 end
107 return ok, err;
108 end
109
87 function command_handlers.version(conn) 110 function command_handlers.version(conn)
88 conn:write("VERSION Mooncached 0.1\r\n"); 111 conn:write("VERSION Mooncached 0.1\r\n");
89 return true; 112 return true;
90 end 113 end
91 114

mercurial