Sha256: 2d0628f5448241b42e4d99a195bce7a1e5a6f3da46ace91949b5ccda0cc58a11

Contents?: true

Size: 742 Bytes

Versions: 22

Compression:

Stored size: 742 Bytes

Contents

module OptimizelyServerSide

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

    include Singleton

    attr_reader :cache_store_instance

    # We are sticking with Activesupprt memory store as gem is to be used with
    # Rails app for now.
    def initialize
      @cache_store_instance = ActiveSupport::Cache::MemoryStore.new(
        expires_in: OptimizelyServerSide.configuration.cache_expiry.send(:minutes)
      )
    end

    class << self

      # fetch is a wrapper on top of Activesupport Fetch to set/get the
      # response via singleton instance
      def fetch(key)
        instance.cache_store_instance.fetch(key) { yield }
      end

    end
  end

end

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
optimizely_server_side-2.0.1 lib/optimizely_server_side/cache.rb
optimizely_server_side-2.0.0 lib/optimizely_server_side/cache.rb
optimizely_server_side-1.2.2 lib/optimizely_server_side/cache.rb
optimizely_server_side-1.2.1 lib/optimizely_server_side/cache.rb
optimizely_server_side-1.2.0 lib/optimizely_server_side/cache.rb
optimizely_server_side-1.0.1 lib/optimizely_server_side/cache.rb
optimizely_server_side-1.0.0 lib/optimizely_server_side/cache.rb
optimizely_server_side-0.0.18 lib/optimizely_server_side/cache.rb
optimizely_server_side-0.0.17 lib/optimizely_server_side/cache.rb
optimizely_server_side-0.0.16 lib/optimizely_server_side/cache.rb
optimizely_server_side-0.0.15 lib/optimizely_server_side/cache.rb
optimizely_server_side-0.0.14 lib/optimizely_server_side/cache.rb
optimizely_server_side-0.0.13 lib/optimizely_server_side/cache.rb
optimizely_server_side-0.0.12 lib/optimizely_server_side/cache.rb
optimizely_server_side-0.0.11 lib/optimizely_server_side/cache.rb
optimizely_server_side-0.0.10 lib/optimizely_server_side/cache.rb
optimizely_server_side-0.0.9 lib/optimizely_server_side/cache.rb
optimizely_server_side-0.0.8 lib/optimizely_server_side/cache.rb
optimizely_server_side-0.0.7 lib/optimizely_server_side/cache.rb
optimizely_server_side-0.0.6 lib/optimizely_server_side/cache.rb