Sha256: b0cbcffcc8cf140d724c3a4a1f8f8a25c1407b3a55a30f263350ded54110809b

Contents?: true

Size: 430 Bytes

Versions: 2

Compression:

Stored size: 430 Bytes

Contents

require 'thread'
class LruRedux::ThreadSafeCache < LruRedux::Cache
  def initialize(size)
    @lock = Mutex.new
    super(size)
  end

  def self.synchronize(*methods)
    methods.each do |method|
      define_method method do |*args, &blk|
      @lock.synchronize do
          super(*args,&blk)
        end
      end
    end
  end

  synchronize :[], :[]=, :each, :to_a, :delete, :count, :valid?, :max_size, :fetch, :getset

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
lru_redux-0.0.6 lib/lru_redux/thread_safe_cache.rb
lru_redux-0.0.5 lib/lru_redux/thread_safe_cache.rb