Sha256: 699504196702703c5ca5526f7b9fd78a528f8d3218beeb858d54382ff06c211d

Contents?: true

Size: 549 Bytes

Versions: 16

Compression:

Stored size: 549 Bytes

Contents

module Monkeyshines
  module Store
    class ReadThruStore < Monkeyshines::Store::TyrantTdbKeyStore

      #
      # If key is absent, save the result of calling the block.
      # If key is present, block is never called.
      #
      # Ex:
      #   rt_store.set(url) do
      #     fetcher.get url # will only be called if url isn't in rt_store
      #   end
      #
      def set key, force=nil, &block
        return if !force && db.has_key?(key)
        result = block.call() or return
        super(key, result)
      end

    end
  end
end

Version data entries

16 entries across 16 versions & 2 rubygems

Version Path
wukong-3.0.0.pre old/wukong/store/read_thru_store.rb
wukong-2.0.2 lib/wukong/store/read_thru_store.rb
wukong-2.0.1 lib/wukong/store/read_thru_store.rb
wukong-2.0.0 lib/wukong/store/read_thru_store.rb
wukong-1.5.4 lib/wukong/store/read_thru_store.rb
wukong-1.5.3 lib/wukong/store/read_thru_store.rb
wukong-1.5.2 lib/wukong/store/read_thru_store.rb
wukong-1.5.1 lib/wukong/store/read_thru_store.rb
wukong-1.5.0 lib/wukong/store/read_thru_store.rb
wukong-1.4.12 lib/wukong/store/read_thru_store.rb
wukong-1.4.11 lib/wukong/store/read_thru_store.rb
monkeyshines-0.2.3 lib/monkeyshines/store/read_thru_store.rb
monkeyshines-0.2.2 lib/monkeyshines/store/read_thru_store.rb
monkeyshines-0.2.1 lib/monkeyshines/store/read_thru_store.rb
monkeyshines-0.2.0 lib/monkeyshines/store/read_thru_store.rb
monkeyshines-0.0.2 lib/monkeyshines/store/read_thru_store.rb