I am using memcached (gem memcache-client) in my application, but I want to use the memory cache store at the same time. I currently have the following in my application.rb:
config.cache_store = :mem_cache_store, {:namespace => "my_namespace_#{Rails.env}"}
and this works fine with commands such as Rails.cache.write(...)
How can I use the ActiveSupport::Cache::MemoryStore for some of my models, and at the same time use memcached for other reasons as I do until now?
I know that ActiveSupport::Cache.lookup_store will return to me a new MemoryStore object. However, I do not know how to continue from this point on? For example, where do I put this command? Where do I store the resulting object? How do I access this object later on from inside my model code? Or shall I follow a completely different way?
Thanks in advance for your help.
Rails.cacheis just a cache store that is created for your convenience. There’s nothing stopping you doing something likeand then when you want to use that store instead of
Rails.cacheyou would doAlthough, as @leonardoborges commented, I’m not sure why you would want to do this