开发者

How to store a value in memcached store from a rails worker

In my rails app, i want to store a value from the worker into the memcached and read it from the application controller. But in the worker i couldn't store the value as below

cache_store.write('db_status','down')

it says, undefined local variable or method cache_store.

How do i configure my worker to write into the memcache store.

i have set the cache store as below

config.action_controller.cache_store = :mem_cache_store 

in my environments 开发者_JAVA百科config. I need to use the same cache store in my worker too.

Thanks


Where does cache_store come from?

If you configure the internal Rails caching feature to connect to Memcached, then you can use

Rails.cache.write("key", "value")
Rails.cache.fetch("key") { ... }
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜