Skip to content

Commit

Permalink
add expriry time 0 test, update exptime 0 parsing in touch command
Browse files Browse the repository at this point in the history
  • Loading branch information
rdarder committed Feb 5, 2012
1 parent 17d42f1 commit 4cc2aba
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
6 changes: 3 additions & 3 deletions command.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,10 +136,10 @@ func (self *TouchCommand) parse(line []string) bool {
}
self.command = line[0]
self.key = line[1]
if exptime < secondsInMonth {
self.exptime = uint32(time.Seconds()) + uint32(exptime);
} else {
if exptime == 0 || exptime > secondsInMonth {
self.exptime = uint32(exptime)
} else {
self.exptime = uint32(time.Seconds()) + uint32(exptime);
}
if line[len(line)-1] == "noreply" {
self.noreply = true
Expand Down
8 changes: 7 additions & 1 deletion test/expirations.t
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/perl

use strict;
use Test::More tests => 15;
use Test::More tests => 18;
use FindBin qw($Bin);
use lib "$Bin/lib";
use MemcachedTest;
Expand Down Expand Up @@ -62,3 +62,9 @@ sleep(2.3);
print $sock "add add 0 2 7\r\naddval3\r\n";
is(scalar <$sock>, "STORED\r\n", "stored add again");
mem_get_is($sock, "add", "addval3");

print $sock "set forever 0 0 6\r\nfooval\r\n";
is(scalar <$sock>, "STORED\r\n", "stored foo");
mem_get_is($sock, "forever", "fooval");
sleep(1.5);
mem_get_is($sock, "forever", "fooval");

0 comments on commit 4cc2aba

Please sign in to comment.