You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: t/145-shdict-list.t
+84Lines changed: 84 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -743,3 +743,87 @@ GET /test
743
743
done
744
744
--- no_error_log
745
745
[error]
746
+
747
+
748
+
749
+
=== TEST 20:pushto an expired list
750
+
--- http_config
751
+
lua_shared_dict dogs 1m;
752
+
--- config
753
+
location = /test {
754
+
content_by_lua_block {
755
+
local dogs = ngx.shared.dogs
756
+
local len, err = dogs:lpush("cc", "1") --add another list to avoid key"aa" be cleaned (run‘ngx_http_lua_shdict_expire(ctx, 1)’ may clean key ,ensure key'aa' not clean ,just expired))
757
+
ifnot len then
758
+
ngx.say("push cc err: ", err)
759
+
end
760
+
local len, err = dogs:lpush("aa", "1")
761
+
ifnot len then
762
+
ngx.say("push1 err: ", err)
763
+
end
764
+
local succ, err = dogs:expire("aa", 0.2)
765
+
ifnotsucc then
766
+
ngx.say("expire err: ",err)
767
+
end
768
+
ngx.sleep(0.3) -- list aa expired
769
+
local len, err = dogs:lpush("aa", "2") --push to an expired list may set as a new list
770
+
ifnot len then
771
+
ngx.say("push2 err: ", err)
772
+
end
773
+
local len, err = dogs:llen("aa") --new list len is1
774
+
ifnot len then
775
+
ngx.say("llen err: ", err)
776
+
else
777
+
ngx.say("aa:len :", dogs:llen("aa"))
778
+
end
779
+
}
780
+
}
781
+
782
+
--- request
783
+
GET /test
784
+
--- response_body
785
+
aa:len :1
786
+
--- no_error_log
787
+
[error]
788
+
789
+
790
+
791
+
=== TEST 21:pushto an expired list then pop many time (more then list len )
792
+
--- http_config
793
+
lua_shared_dict dogs 1m;
794
+
--- config
795
+
location = /test {
796
+
content_by_lua_block {
797
+
local dogs = ngx.shared.dogs
798
+
local len, err = dogs:lpush("cc", "1") --add another list to avoid key"aa" be cleaned (run‘ngx_http_lua_shdict_expire(ctx, 1)’ may clean key ,ensure key'aa' not clean ,just expired))
799
+
ifnot len then
800
+
ngx.say("push cc err: ", err)
801
+
end
802
+
local len, err = dogs:lpush("aa", "1")
803
+
ifnot len then
804
+
ngx.say("push1 err: ", err)
805
+
end
806
+
local succ, err = dogs:expire("aa", 0.2)
807
+
ifnotsucc then
808
+
ngx.say("expire err: ",err)
809
+
end
810
+
ngx.sleep(0.3) -- list aa expired
811
+
local len, err = dogs:lpush("aa", "2") --push to an expired list may set as a new list
0 commit comments