2

Just getting starting using memcached with a rails app

I have the following fragment:

<% cache("home_main", :expires_in => 1.minute) do %>

and would like to query the value via the Rails console but:

 => nil 
1.9.1 :012 > Rails.cache.read('home_main')
 => nil 
1.9.1 :013 > Rails.cache.fetch('home_main')
 => nil 
1.9.1 :014 >

How would I query to get that fragment back? Or how would I see what the current cache keys are?

Also, how do I clear the cache?

From Rails.cache.stats

conn_yields: '0'
 bytes: '409071'
 curr_items: '23'
 total_items: '157'
 evictions: '0'
 reclaimed: '0'
=> nil 

>Rails.cache.clear

....
>Rails.cache.stats 
...
  bytes: '409071'
  curr_items: '23'
  total_items: '157'
  evictions: '0'
  reclaimed: '0'
 => nil 
1.9.1 :017 >

How would I truly clear memcached?

thx

timpone
  • 19,235
  • 36
  • 121
  • 211

1 Answers1

0

These are the 3 primary memcache methods I use:

Add a value to the cache:

CACHE.set(CACHE_KEY, CACHE_VALUE)

Read a value from the cache:

CACHE.get(CACHE_KEY)

Clear the cache for a specific key:

CACHE.delete(CACHE_KEY)

Hope this helps... Cheers.