-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add touch command with test file and docs
- Loading branch information
1 parent
f1995f0
commit 0e3c76e
Showing
5 changed files
with
173 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -102,3 +102,4 @@ | |
./t/nested_prefix.t | ||
./t/keyscan.t | ||
./t/prefixscan.t | ||
./t/touch.t |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -95,3 +95,4 @@ | |
./t/nested_prefix.t | ||
./t/keyscan.t | ||
./t/prefixscan.t | ||
./t/touch.t |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
#!/usr/bin/perl | ||
|
||
use strict; | ||
use Test::More tests => 22; | ||
use FindBin qw($Bin); | ||
use lib "$Bin/lib"; | ||
use MemcachedTest; | ||
|
||
my $engine = shift; | ||
my $server = get_memcached($engine); | ||
my $sock = $server->sock; | ||
|
||
my $cmd; | ||
my $val; | ||
my $rst; | ||
my $expire; | ||
my $msg; | ||
|
||
# Initialize | ||
$cmd = "set key 0 0 5"; $val = "datum"; $rst = "STORED"; | ||
mem_cmd_is($sock, $cmd, $val, $rst); | ||
$cmd = "lop create lkey 0 0 1 error"; $rst = "CREATED"; | ||
mem_cmd_is($sock, $cmd, "", $rst); | ||
$cmd = "sop create skey 0 0 1 error"; $rst = "CREATED"; | ||
mem_cmd_is($sock, $cmd, "", $rst); | ||
$cmd = "mop create mkey 0 0 1 error"; $rst = "CREATED"; | ||
mem_cmd_is($sock, $cmd, "", $rst); | ||
$cmd = "bop create bkey 0 0 1 error"; $rst = "CREATED"; | ||
mem_cmd_is($sock, $cmd, "", $rst); | ||
|
||
# Success Cases | ||
# key value | ||
$cmd = "touch key 1"; $rst = "TOUCHED"; | ||
mem_cmd_is($sock, $cmd, "", $rst); | ||
$cmd = "getattr key expiretime"; | ||
$rst = "ATTR expiretime=1\n" | ||
. "END"; | ||
$msg = "success touch at key value type"; | ||
mem_cmd_is($sock, $cmd, "", $rst, $msg); | ||
# list | ||
$cmd = "touch lkey 1"; $rst = "TOUCHED"; | ||
mem_cmd_is($sock, $cmd, "", $rst); | ||
$cmd = "getattr lkey expiretime"; | ||
$rst = "ATTR expiretime=1\n" | ||
. "END"; | ||
$msg = "success touch at list collection"; | ||
mem_cmd_is($sock, $cmd, "", $rst, $msg); | ||
# set | ||
$cmd = "touch skey 1"; $rst = "TOUCHED"; | ||
mem_cmd_is($sock, $cmd, "", $rst); | ||
$cmd = "getattr skey expiretime"; | ||
$rst = "ATTR expiretime=1\n" | ||
. "END"; | ||
$msg = "success touch at set collection"; | ||
mem_cmd_is($sock, $cmd, "", $rst, $msg); | ||
# map | ||
$cmd = "touch mkey 1"; $rst = "TOUCHED"; | ||
mem_cmd_is($sock, $cmd, "", $rst); | ||
$cmd = "getattr mkey expiretime"; | ||
$rst = "ATTR expiretime=1\n" | ||
. "END"; | ||
$msg = "success touch at map collection"; | ||
mem_cmd_is($sock, $cmd, "", $rst, $msg); | ||
#btree | ||
$cmd = "touch bkey 1"; $rst = "TOUCHED"; | ||
mem_cmd_is($sock, $cmd, "", $rst); | ||
$cmd = "getattr bkey expiretime"; | ||
$rst = "ATTR expiretime=1\n" | ||
. "END"; | ||
$msg = "success touch at btree collection"; | ||
mem_cmd_is($sock, $cmd, "", $rst, $msg); | ||
# set with unix time | ||
$cmd = "set key 0 0 5"; $val = "datum"; $rst = "STORED"; | ||
mem_cmd_is($sock, $cmd, $val, $rst); | ||
$expire = time() + 1; | ||
$cmd = "touch key $expire"; $rst = "TOUCHED"; | ||
mem_cmd_is($sock, $cmd, "", $rst); | ||
$cmd = "getattr key expiretime"; | ||
$rst = "ATTR expiretime=1\n" | ||
. "END"; | ||
$msg = "success touch with unix time"; | ||
mem_cmd_is($sock, $cmd, "", $rst, $msg); | ||
|
||
# Fail Cases | ||
# not exist key | ||
$cmd = "touch key 1"; $rst = "NOT_FOUND"; $msg = "failed with not exist key which is already expired"; | ||
sleep(1.2); | ||
mem_cmd_is($sock, $cmd, "", $rst, $msg); | ||
# bad value | ||
$cmd = "set key 0 0 5"; $val = "datum"; $rst = "STORED"; | ||
mem_cmd_is($sock, $cmd, $val, $rst); | ||
$cmd = "touch key str"; $rst = "CLIENT_ERROR bad value"; $msg = "failed with bad value at exptime"; | ||
mem_cmd_is($sock, $cmd, "", $rst, $msg); | ||
|
||
# Finalize | ||
$cmd = "delete key"; $rst = "DELETED"; | ||
mem_cmd_is($sock, $cmd, "", $rst); | ||
|
||
# after test | ||
release_memcached($engine, $server); |