From 4cc2abafd3a381a2fc5a79838c060cf93afc23a7 Mon Sep 17 00:00:00 2001 From: Rafael Darder Date: Sun, 5 Feb 2012 00:59:44 -0300 Subject: [PATCH] add expriry time 0 test, update exptime 0 parsing in touch command --- command.go | 6 +++--- test/expirations.t | 8 +++++++- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/command.go b/command.go index 8701563..7d45c2d 100644 --- a/command.go +++ b/command.go @@ -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 diff --git a/test/expirations.t b/test/expirations.t index c92125a..0c2cc08 100755 --- a/test/expirations.t +++ b/test/expirations.t @@ -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; @@ -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");