class Zold::CachedWallets

Collection of local wallets

Public Class Methods

new(wallets) click to toggle source
Calls superclass method
# File lib/zold/cached_wallets.rb, line 35
def initialize(wallets)
  @wallets = wallets
  @zache = Zache.new
  @clean = ThreadPool.new('cached-wallets')
  @clean.add do
    Endless.new('cached_wallets').run do
      sleep 5
      @zache.clean
    end
  end
  super(wallets)
end

Public Instance Methods

acq(id, exclusive: false) { |c| ... } click to toggle source
# File lib/zold/cached_wallets.rb, line 48
def acq(id, exclusive: false)
  @wallets.acq(id, exclusive: exclusive) do |wallet|
    c = @zache.get(id.to_s, lifetime: 15) { wallet }
    res = yield c
    c.flush if exclusive
    res
  end
end