Hi all,
I am working Couchbase with Ruby on Rails, after googling, I have written below code base on what I’ve found from the Internet.
config/environments, development.rb, production.rb and test.rb
config.cache_store = :dalli_store, ‘localhost:11211’, {:namespace => ‘TestServer’, :expires_in => 5.seconds, :compress => true}
Then in config/initializers/session_store.rb
Rails.application.config.session_store ActionDispatch::Session::CacheStore, :expire_after => 5.seconds
When I am storing data to the memcached, I use below coding:
$mc_server = Dalli::Client.new(‘localhost:11211’, username: ‘TestMemcached’, password: ‘123123’)
$mc_server.set(‘testdata’, ‘111’, 3.seconds)
After this, I can see that in the Couchbase web console, the item count under my TestMemcached bucket increased to 1, but after a long long time, the the item is still here; which I expect should be expired and removed back to 0.
Did I misunderstand something or done something wrong? I’d like to have memcached store some of my data for a short period, i.e. 30 seconds, and expire and remove it afterward. Could anyone kindly help advise on this?
Many thanks!