anusuya
anusuya

Reputation: 653

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 config. I need to use the same cache store in my worker too.

Thanks

Upvotes: 2

Views: 954

Answers (1)

Simone Carletti
Simone Carletti

Reputation: 176472

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") { ... }

Upvotes: 2

Related Questions