class OptimizelyServerSide::Cache

Maintains the API config response in Memory store cache. user Activesupport MemoryStore store.

Attributes

cache_store_instance[R]

Public Class Methods

fetch(key) { || ... } click to toggle source

fetch is a wrapper on top of Activesupport Fetch to set/get the response via singleton instance

# File lib/optimizely_server_side/cache.rb, line 23
def fetch(key)
  instance.cache_store_instance.fetch(key) { yield }
end
new() click to toggle source

We are sticking with Activesupprt memory store as gem is to be used with Rails app for now.

# File lib/optimizely_server_side/cache.rb, line 13
def initialize
  @cache_store_instance = ActiveSupport::Cache::MemoryStore.new(
    expires_in: OptimizelyServerSide.configuration.cache_expiry.send(:minutes)
  )
end