Sha256: 1c676388a4b5d90cdc4bebe4cce4686262192cc5465c2c12be8d730494aed899

Contents?: true

Size: 387 Bytes

Versions: 2

Compression:

Stored size: 387 Bytes

Contents

require 'ipinfo/cache/cache_interface'
require 'lrucache'

module IPinfo
  class DefaultCache < CacheInterface

    def initialize(ttl, max_size)
      @cache = LRUCache.new(:ttl => ttl, :max_size => max_size)
    end

    def get(key)
      @cache[key]
    end

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

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

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
IPinfo-0.1.2 lib/ipinfo/cache/default_cache.rb
IPinfo-0.1.1 lib/ipinfo/cache/default_cache.rb