-
Notifications
You must be signed in to change notification settings - Fork 2
Closed
Description
Hi, I want to use cache shard to count how many people are online on my website.
When user visit my website, will poll peridly to report he is still online.
I want to use Cache::MemoryStore to create items, but expired in 2 minutes.
Then, I can use cache.keys.size to get the current alive users count.
But, It's seem like cache.keys not work as expected.
please check following example code:
require "./src/cache"
cache = Cache::MemoryStore(String, String).new(expires_in: 2.seconds)
cache.fetch("foo") { "foo" }
cache.fetch("bar", expires_in: 5.seconds) { "bar" }
p! cache.keys # Set{"foo", "bar"}, it correct.
sleep 3.seconds
p! cache.exists?("foo") # false
p! cache.exists?("bar") # true
p! cache.keys # => Set{"foo", "bar"}, foo is expired, and not exists?, it should be Set{"bar"}, right?Thanks!
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels