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.5.17 vendor/bundle/gems/dragonfly-0.9.12/lib/dragonfly/simple_cache.rb
classiccms-0.5.16 vendor/bundle/gems/dragonfly-0.9.12/lib/dragonfly/simple_cache.rb
classiccms-0.5.15 vendor/bundle/gems/dragonfly-0.9.12/lib/dragonfly/simple_cache.rb
classiccms-0.5.14 vendor/bundle/gems/dragonfly-0.9.12/lib/dragonfly/simple_cache.rb
classiccms-0.5.13 vendor/bundle/gems/dragonfly-0.9.12/lib/dragonfly/simple_cache.rb
classiccms-0.5.12 vendor/bundle/gems/dragonfly-0.9.12/lib/dragonfly/simple_cache.rb
classiccms-0.5.11 vendor/bundle/gems/dragonfly-0.9.12/lib/dragonfly/simple_cache.rb
classiccms-0.5.10 vendor/bundle/gems/dragonfly-0.9.12/lib/dragonfly/simple_cache.rb
classiccms-0.5.9 vendor/bundle/gems/dragonfly-0.9.12/lib/dragonfly/simple_cache.rb
classiccms-0.5.8 vendor/bundle/gems/dragonfly-0.9.12/lib/dragonfly/simple_cache.rb
classiccms-0.5.7 vendor/bundle/gems/dragonfly-0.9.12/lib/dragonfly/simple_cache.rb
classiccms-0.5.6 vendor/bundle/gems/dragonfly-0.9.12/lib/dragonfly/simple_cache.rb
classiccms-0.5.5 vendor/bundle/gems/dragonfly-0.9.12/lib/dragonfly/simple_cache.rb
classiccms-0.5.2 vendor/bundle/gems/dragonfly-0.9.12/lib/dragonfly/simple_cache.rb
classiccms-0.5.1 vendor/bundle/gems/dragonfly-0.9.12/lib/dragonfly/simple_cache.rb
classiccms-0.5.0 vendor/bundle/gems/dragonfly-0.9.12/lib/dragonfly/simple_cache.rb
classiccms-0.4.2 vendor/bundle/gems/dragonfly-0.9.12/lib/dragonfly/simple_cache.rb
classiccms-0.4.1 vendor/bundle/gems/dragonfly-0.9.12/lib/dragonfly/simple_cache.rb
classiccms-0.4.0 vendor/bundle/gems/dragonfly-0.9.12/lib/dragonfly/simple_cache.rb
classiccms-0.3.9 vendor/bundle/gems/dragonfly-0.9.12/lib/dragonfly/simple_cache.rb