diff options
| author | ruki <[email protected]> | 2020-12-21 22:38:24 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2020-12-21 22:38:24 +0800 |
| commit | bcc7f92bf3779ab59dd7ab8783ba0eb27cc9be89 (patch) | |
| tree | b51be65a5b285637403b35885afe8823bd46aa10 /tests/modules | |
| parent | 28696782d6d96f03d05198dc956901f39b1b1a23 (diff) | |
impl localcache and globalcache
Diffstat (limited to 'tests/modules')
| -rw-r--r-- | tests/modules/cache/test.lua | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/tests/modules/cache/test.lua b/tests/modules/cache/test.lua index ad37ccdb8..0096f0f03 100644 --- a/tests/modules/cache/test.lua +++ b/tests/modules/cache/test.lua @@ -1,4 +1,6 @@ import("core.cache.memcache") +import("core.cache.localcache") +import("core.cache.globalcache") function test_memcache(t) memcache.set("mycache", "xyz", {1, 2, 3}) @@ -13,3 +15,28 @@ function test_memcache(t) t:are_equal(memcache.get2("mycache", "foo", "bar"), nil) end +function test_localcache(t) + localcache.set("mycache", "xyz", {1, 2, 3}) + localcache.set2("mycache", "foo", "bar", "1") + t:are_equal(localcache.get("mycache", "xyz"), {1, 2, 3}) + t:are_equal(localcache.get2("mycache", "foo", "bar"), "1") + localcache.clear("mycache") + t:are_equal(localcache.get2("mycache", "foo", "bar"), nil) + localcache.set2("mycache", "foo", "bar", "1") + localcache.clear() + t:are_equal(localcache.get("mycache", "xyz"), nil) + t:are_equal(localcache.get2("mycache", "foo", "bar"), nil) +end + +function test_globalcache(t) + globalcache.set("mycache", "xyz", {1, 2, 3}) + globalcache.set2("mycache", "foo", "bar", "1") + t:are_equal(globalcache.get("mycache", "xyz"), {1, 2, 3}) + t:are_equal(globalcache.get2("mycache", "foo", "bar"), "1") + globalcache.clear("mycache") + t:are_equal(globalcache.get2("mycache", "foo", "bar"), nil) + globalcache.set2("mycache", "foo", "bar", "1") + globalcache.clear() + t:are_equal(globalcache.get("mycache", "xyz"), nil) + t:are_equal(globalcache.get2("mycache", "foo", "bar"), nil) +end |
