Sha256: a2a436536857d188ce2a24ba29b63c3cf0fcc789559ddebe57d1f42d9dfa691d

Contents?: true

Size: 441 Bytes

Versions: 4

Compression:

Stored size: 441 Bytes

Contents

module Storyblok
  class Cache
    def self.client=(client)
      @client = client
    end

    def self.client
      @client
    end

    def cache(key, expire = nil)
      if expire == 0
        return yield(self)
      end

      if (value = @client.get(key)).nil?
        value = yield(self)
        @client.set(key, value)
        @client.expire(key, expire) if expire
        value
      else
        value
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
storyblok-1.0.3 lib/storyblok/cache.rb
storyblok-1.0.2 lib/storyblok/cache.rb
storyblok-1.0.1 lib/storyblok/cache.rb
storyblok-1.0.0 lib/storyblok/cache.rb