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/043-shdict.t
+74
Original file line number
Diff line number
Diff line change
@@ -1962,3 +1962,77 @@ nil
1962
1962
nil
1963
1963
--- no_error_log
1964
1964
[error]
1965
+
1966
+
1967
+
1968
+
=== TEST 88:pushto an expired list
1969
+
--- stream_config
1970
+
lua_shared_dict dogs 1m;
1971
+
--- stream_server_config
1972
+
content_by_lua_block {
1973
+
local dogs = ngx.shared.dogs
1974
+
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))
1975
+
ifnot len then
1976
+
ngx.say("push cc err: ", err)
1977
+
end
1978
+
local len, err = dogs:lpush("aa", "1")
1979
+
ifnot len then
1980
+
ngx.say("push1 err: ", err)
1981
+
end
1982
+
local succ, err = dogs:expire("aa", 0.2)
1983
+
ifnotsucc then
1984
+
ngx.say("expire err: ",err)
1985
+
end
1986
+
ngx.sleep(0.3) -- list aa expired
1987
+
local len, err = dogs:lpush("aa", "2") --push to an expired list may set as a new list
1988
+
ifnot len then
1989
+
ngx.say("push2 err: ", err)
1990
+
end
1991
+
local len, err = dogs:llen("aa") --new list len is1
1992
+
ifnot len then
1993
+
ngx.say("llen err: ", err)
1994
+
else
1995
+
ngx.say("aa:len :", dogs:llen("aa"))
1996
+
end
1997
+
}
1998
+
--- stream_response
1999
+
aa:len :1
2000
+
--- no_error_log
2001
+
[error]
2002
+
2003
+
2004
+
2005
+
=== TEST 89:pushto an expired list then pop many time (more then list len )
2006
+
--- stream_config
2007
+
lua_shared_dict dogs 1m;
2008
+
--- stream_server_config
2009
+
content_by_lua_block {
2010
+
local dogs = ngx.shared.dogs
2011
+
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))
2012
+
ifnot len then
2013
+
ngx.say("push cc err: ", err)
2014
+
end
2015
+
local len, err = dogs:lpush("aa", "1")
2016
+
ifnot len then
2017
+
ngx.say("push1 err: ", err)
2018
+
end
2019
+
local succ, err = dogs:expire("aa", 0.2)
2020
+
ifnotsucc then
2021
+
ngx.say("expire err: ",err)
2022
+
end
2023
+
ngx.sleep(0.3) -- list aa expired
2024
+
local len, err = dogs:lpush("aa", "2") --push to an expired list may set as a new list
0 commit comments