Closed forrest closed 10 years ago
You can't reference the global as if it's a Dalli::Client instance. You must check out a connection from the pool via with
and use it:
Rails.cache.dalli.with do |client|
client.multi do
array_of_items_to_write_back.each {|key, value|
client.set(key, value)
}
end
end
And thanks for the feedback, good to see people playing with the new pool support.
Thanks @mperham for the quick response and the great gems. That makes sense for the multi set. Does this mean I need to wrap every spot I use Rails.cache.read(key)
with the with
block?
How about multi_read
? I'm seeing this error:
undefined method 'read_multi' for #<Dalli::Client:0x007faf5115ca18>)
Thanks again for all the help
No, any normal Rails.cache.method will implicitly use the pool automatically. You need to do this when you are trying to use dalli directly.
You need to show me the actual code so I know what you are doing wrong.
It seems like it was something weird with the memcached server I was running locally. Once I tried this in staging, everything worked like a dream. Thanks again for all the help.
Hey,
I've been using dalli's read_multi and multi (combined with set) to try optimize our memcache. Both systems work with dalli directly.
We're now going to multithreading and trying to use
connection_pool
as you recommend in the readme for https://github.com/mperham/dalli, but we keep getting errors._readmulti raises:
NoMethodError (undefined method 'split' for nil:NilClass)
Multi with set
raises `NoMethodError (undefined method 'multi' for #):``
Any tips on how to use connection_pool with our batch functionality?
Thanks