Sha256: ee374efc65158d15b680408721e47705889fa39d15180f3351f68783b5753e65

Contents?: true

Size: 597 Bytes

Versions: 9

Compression:

Stored size: 597 Bytes

Contents

module Dassets; end
module Dassets::Cache

  class MemCache
    require 'thread'

    # this is a thread-safe in-memory cache

    def initialize
      @hash = {}
      @write_mutex = ::Mutex.new
    end

    def keys
      @hash.keys
    end

    def [](key)
      @hash[key]
    end

    def []=(key, value)
      @write_mutex.synchronize{ @hash[key] = value }
    end

  end

  class NoCache

    # This is a no-op cache object.  This is the default cache in use and "turns
    # off caching.

    def keys
      []
    end

    def [](key)
    end

    def []=(key, value)
    end

  end

end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
dassets-0.14.5 lib/dassets/cache.rb
dassets-0.14.4 lib/dassets/cache.rb
dassets-0.14.3 lib/dassets/cache.rb
dassets-0.14.2 lib/dassets/cache.rb
dassets-0.14.1 lib/dassets/cache.rb
dassets-0.14.0 lib/dassets/cache.rb
dassets-0.13.2 lib/dassets/cache.rb
dassets-0.13.1 lib/dassets/cache.rb
dassets-0.13.0 lib/dassets/cache.rb