Sha256: efcb8a3a743377632d82359d380683e4eebfa8c7c511a487f10aec6908154aa4

Contents?: true

Size: 388 Bytes

Versions: 76

Compression:

Stored size: 388 Bytes

Contents

module Dragonfly
  class SimpleCache < Hash
    
    def initialize(max_size)
      @max_size = max_size
      @keys = []
    end
    
    attr_reader :max_size
    
    def []=(key, value)
      if !has_key?(key)
        @keys << key
        if size == max_size
          key_to_purge = @keys.shift
          delete(key_to_purge)
        end
      end
      super
    end
    
  end
end

Version data entries

76 entries across 76 versions & 4 rubygems

Version Path
dragonfly-0.9.0 lib/dragonfly/simple_cache.rb
dragonfly-0.8.4 lib/dragonfly/simple_cache.rb
oahu-dragonfly-0.8.2 lib/dragonfly/simple_cache.rb
fog-dragonfly-0.8.2 lib/dragonfly/simple_cache.rb
dragonfly-0.8.2 lib/dragonfly/simple_cache.rb
fog-dragonfly-0.8.1 lib/dragonfly/simple_cache.rb
dragonfly-0.8.1 lib/dragonfly/simple_cache.rb
dragonfly-0.8.0 lib/dragonfly/simple_cache.rb
dragonfly-0.7.7 lib/dragonfly/simple_cache.rb
dragonfly-0.7.6 lib/dragonfly/simple_cache.rb
dragonfly-0.7.5 lib/dragonfly/simple_cache.rb
dragonfly-0.7.4 lib/dragonfly/simple_cache.rb
dragonfly-0.7.3 lib/dragonfly/simple_cache.rb
dragonfly-0.7.2 lib/dragonfly/simple_cache.rb
dragonfly-0.7.1 lib/dragonfly/simple_cache.rb
dragonfly-0.7.0 lib/dragonfly/simple_cache.rb