checking ttl for Rails.cache object

风流意气都作罢 提交于 2020-05-15 06:00:46

问题


So I have some items stored in Rails.cache and I always write them with :expires_in => 5.minutes

My question is, is there a way to see what the ttl is on a cache entry?

I know the entry class in activesupport has a method but I can't seem to get an entry object out of Rails.cache methods.

I'm implementing rate limiting by the way.


回答1:


You can check ttl in Rails cache using command below.

Rails.cache.data.ttl("yourkey")


来源:https://stackoverflow.com/questions/24896449/checking-ttl-for-rails-cache-object

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!