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
classiccms-0.7.5 vendor/bundle/gems/dragonfly-0.9.12/lib/dragonfly/simple_cache.rb
classiccms-0.7.4 vendor/bundle/gems/dragonfly-0.9.12/lib/dragonfly/simple_cache.rb
classiccms-0.7.3 vendor/bundle/gems/dragonfly-0.9.12/lib/dragonfly/simple_cache.rb
classiccms-0.7.2 vendor/bundle/gems/dragonfly-0.9.12/lib/dragonfly/simple_cache.rb
classiccms-0.7.1 vendor/bundle/gems/dragonfly-0.9.12/lib/dragonfly/simple_cache.rb
classiccms-0.7.0 vendor/bundle/gems/dragonfly-0.9.12/lib/dragonfly/simple_cache.rb
dragonfly-0.9.15 lib/dragonfly/simple_cache.rb
dragonfly-0.8.6 lib/dragonfly/simple_cache.rb
dragonfly-0.9.14 lib/dragonfly/simple_cache.rb
dragonfly-0.9.13 lib/dragonfly/simple_cache.rb
classiccms-0.6.9 vendor/bundle/gems/dragonfly-0.9.12/lib/dragonfly/simple_cache.rb
classiccms-0.6.8 vendor/bundle/gems/dragonfly-0.9.12/lib/dragonfly/simple_cache.rb
classiccms-0.6.7 vendor/bundle/gems/dragonfly-0.9.12/lib/dragonfly/simple_cache.rb
classiccms-0.6.6 vendor/bundle/gems/dragonfly-0.9.12/lib/dragonfly/simple_cache.rb
classiccms-0.6.5 vendor/bundle/gems/dragonfly-0.9.12/lib/dragonfly/simple_cache.rb
classiccms-0.6.4 vendor/bundle/gems/dragonfly-0.9.12/lib/dragonfly/simple_cache.rb
classiccms-0.6.3 vendor/bundle/gems/dragonfly-0.9.12/lib/dragonfly/simple_cache.rb
classiccms-0.6.2 vendor/bundle/gems/dragonfly-0.9.12/lib/dragonfly/simple_cache.rb
classiccms-0.6.1 vendor/bundle/gems/dragonfly-0.9.12/lib/dragonfly/simple_cache.rb
classiccms-0.6.0 vendor/bundle/gems/dragonfly-0.9.12/lib/dragonfly/simple_cache.rb