Sha256: c6b5fd49e0e664eff922f9a16230f0d80c7198ca63bf0b77d51e217234cf39ac

Contents?: true

Size: 411 Bytes

Versions: 5

Compression:

Stored size: 411 Bytes

Contents

# frozen_string_literal: true

require 'ipinfo/cache/cache_interface'
require 'lru_redux'

class IPinfo::DefaultCache < IPinfo::CacheInterface
    def initialize(ttl, max_size)
        @cache = LruRedux::TTL::Cache.new(max_size, ttl)
    end

    def get(key)
        @cache[key]
    end

    def set(key, value)
        @cache[key] = value
    end

    def contains?(key)
        !@cache[key].nil?
    end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
IPinfo-2.2.4 lib/ipinfo/cache/default_cache.rb
IPinfo-2.2.3 lib/ipinfo/cache/default_cache.rb
IPinfo-2.2.1 lib/ipinfo/cache/default_cache.rb
IPinfo-1.1.0 lib/ipinfo/cache/default_cache.rb
IPinfo-1.0.1 lib/ipinfo/cache/default_cache.rb