Advertisement
Guest User

Untitled

a guest
Jun 20th, 2019
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.46 KB | None | 0 0
  1. Rails.cache.write('temp',Date.today,:expires_in => 60.seconds)
  2.  
  3. config.action_controller.perform_caching = true
  4.  
  5. config.cache_store = :memory_store
  6.  
  7. if expires_in > 0 && !options[:raw]
  8. # Set the memcache expire a few minutes in the future to support race condition ttls on read
  9. expires_in += 5.minutes
  10. end
  11.  
  12. output_json = Rails.cache.fetch('temp',expires_in: 1.minute,race_condition_ttl:3) do
  13. my_expansive_operation().to_json
  14. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement