Sha256: a22e7d8c9a4a04a750f7dba5c58a755261aa7ef3dbef00d5757f2ec44d4bb1a8

Contents?: true

Size: 628 Bytes

Versions: 6

Compression:

Stored size: 628 Bytes

Contents

module Dassets; end
module Dassets::Cache

  class MemCache
    require 'thread'

    # this is a thread-safe in-memory cache for use with the `SourceCache`

    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

6 entries across 6 versions & 1 rubygems

Version Path
dassets-0.12.0 lib/dassets/cache.rb
dassets-0.11.0 lib/dassets/cache.rb
dassets-0.10.1 lib/dassets/cache.rb
dassets-0.10.0 lib/dassets/cache.rb
dassets-0.9.0 lib/dassets/cache.rb
dassets-0.8.0 lib/dassets/cache.rb