How to get cache expiration date in Rails 3 using the Dalli gem?

1.2k views Asked by At

I have a Rails 3 application that uses the Dalli gem to manage its cache.

I need to check if a certain part of the application is setting the expiration date of the cache correctly, but can't find a way to manually check that on a specific fragment.

I found this answer, but it doesn't work with Dalli.

Is there another way?

1

There are 1 answers

0
fantaxy025025 On
  1. You have a mistake when use read_entry method.

    Rails.cache.send(:read_entry,'cache/entry/key',{})
    

    The 'cache/entry/key' should not begin with the namespace.

    for example:

    The namespace is 'aaa', the key is 'aaa:a_key_name', then the 'cache/entry/key' should be 'a_key_name'.

  2. this script may work: https://gist.github.com/bkimble/1365005