ruby on rails - How to use two different memcache instances on heroku -


i storing database query results in memcache on heroku. using memcachier addon on heroku. example if have cache user's tasks in memcache. this:

 def cached_tasks    rails.cache.fetch([:users, id, :tasks], :expires_in => 12.hours) { tasks.to_a }    end 

this works fine want use 2 different memcache instances store data.

why?

one used frequently, data changes , big data objects , never change or rarely.

how can use 2 different instances , specify cached_tasks should stored in memcache_instance_1 , other cached_images should stored in memcache_instance_2

why not use same one:

because need flush whole cache , flush big data don't want to.

any suggestions?

declare 3 new env variables heroku app

big_memcachier_servers big_memcachier_username big_memcachier_password 

add file called big_cache.rb in config\initializers directory:

module rails   def self.big_cache     @big_cache ||= activesupport::cache::dallistore.new(       (env["big_memcachier_servers"] || "").split(","),       :username => env["big_memcachier_username"],       :password => env["big_memcachier_password"])   end end 

now can access 2nd cache follows:

rails.big_cache.fetch(..) 

Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -