⚝
One Hat Cyber Team
⚝
Your IP:
216.73.216.124
Server IP:
50.28.103.30
Server:
Linux host.jcukjv-lwsites.com 4.18.0-553.22.1.el8_10.x86_64 #1 SMP Tue Sep 24 05:16:59 EDT 2024 x86_64
Server Software:
nginx/1.28.0
PHP Version:
8.3.12
Buat File
|
Buat Folder
Eksekusi
Dir :
~
/
www
/
server
/
nginx
/
src
/
lua-resty-lrucache-0.13
/
t
/
View File Name :
004-flush-all.t
# vim:set ft= ts=4 sw=4 et fdm=marker: use lib '.'; use t::TestLRUCache; repeat_each(2); plan tests => repeat_each() * (blocks() * 3); no_long_string(); run_tests(); __DATA__ === TEST 1: flush_all() deletes all keys (cache partial occupied) --- config location = /t { content_by_lua_block { local lrucache = require "resty.lrucache" local N = 4 local c = lrucache.new(N) for i = 1, N / 2 do c:set("key " .. i, i) end c:flush_all() for i = 1, N do local key = "key " .. i local v = c:get(key) ngx.say(i, ": ", v) end ngx.say("++") for i = 1, N + 1 do c:set("key " .. i, i) end for i = 1, N + 1 do ngx.say(i, ": ", (c:get("key " .. i))) end } } --- response_body 1: nil 2: nil 3: nil 4: nil ++ 1: nil 2: 2 3: 3 4: 4 5: 5 === TEST 2: flush_all() deletes all keys (cache fully occupied) --- config location = /t { content_by_lua_block { local lrucache = require "resty.lrucache" local N = 4 local c = lrucache.new(N) for i = 1, N + 1 do c:set("key " .. i, i) end ngx.say(c:count()) c:flush_all() ngx.say(c:count()) for i = 1, N + 1 do local key = "key " .. i local v = c:get(key) ngx.say(i, ": ", v) end ngx.say("++") for i = 1, N + 1 do c:set("key " .. i, i) end for i = 1, N + 1 do ngx.say(i, ": ", (c:get("key " .. i))) end } } --- response_body 4 0 1: nil 2: nil 3: nil 4: nil 5: nil ++ 1: nil 2: 2 3: 3 4: 4 5: 5 === TEST 3: flush_all() flush empty cache store --- config location = /t { content_by_lua_block { local lrucache = require "resty.lrucache" local N = 4 local c = lrucache.new(4) c:flush_all() for i = 1, N do local key = "key " .. i local v = c:get(key) ngx.say(i, ": ", v) end ngx.say("++") for i = 1, N + 1 do c:set("key " .. i, i) end for i = 1, N + 1 do ngx.say(i, ": ", (c:get("key " .. i))) end } } --- response_body 1: nil 2: nil 3: nil 4: nil ++ 1: nil 2: 2 3: 3 4: 4 5: 5