Sha256: 7f9ca1a257b21836431d97067f171686fb0919dff0507d836f90dd3189bd3915

Contents?: true

Size: 656 Bytes

Versions: 3

Compression:

Stored size: 656 Bytes

Contents

require 'monitor'

class Mize::DefaultCache
  include MonitorMixin

  def initialize
    @data = {}
  end

  def clear(options = nil)
    @data.clear
    self
  end

  def exist?(name, options = nil)
    @data.key?(name)
  end

  def read(name, options = nil)
    @data.fetch(name, nil)
  end

  def write(name, value, options = nil)
    @data.store(name, value)
  end

  def delete(name, options = nil)
    @data.delete(name)
  end

  def each_name(&block)
    @data.each_key(&block)
    self
  end

  def initialize_dup(other)
    super
    other.instance_variable_set :@data, @data.dup
  end

  alias prototype dup

  conform_to Mize::CacheProtocol
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
mize-0.4.1 lib/mize/default_cache.rb
mize-0.4.0 lib/mize/default_cache.rb
mize-0.3.5 lib/mize/default_cache.rb