Sha256: 519a8d452d4f2fb85b6d9c28311b897d8795f9a531580e551917aae216931ec2

Contents?: true

Size: 413 Bytes

Versions: 2

Compression:

Stored size: 413 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

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
lru_redux-0.0.4 lib/lru_redux/thread_safe_cache.rb
lru_redux-0.0.3 lib/lru_redux/thread_safe_cache.rb