Sha256: 355f7cc60ce1ca11d0ab85769716c34f250db1f87b8380490c3cd20a4aa7058c

Contents?: true

Size: 761 Bytes

Versions: 16

Compression:

Stored size: 761 Bytes

Contents

begin
  require "rufus/tokyo"
rescue LoadError
  puts "You need the rufus gem to use the Rufus moneta store"
  exit
end

module Moneta
  class BasicRufus < ::Rufus::Tokyo::Cabinet 
    include Defaults
       
    def initialize(options = {})
      file = options[:file]
      super("#{file}.tch")
    end
    
    def key?(key)
      !!self[key]
    end
    
    def [](key)
      if val = super
        Marshal.load(val.unpack("m")[0])
      end
    end
    
    def []=(key, value)
      super(key, [Marshal.dump(value)].pack("m"))
    end    
  end
  
  class Rufus < BasicRufus
    include Expires
    
    def initialize(options = {})
      file = options[:file]
      @expiration = BasicRufus.new(:file => "#{file}_expires")
      super
    end
  end
end

Version data entries

16 entries across 16 versions & 9 rubygems

Version Path
aeden-moneta-0.6.2 lib/moneta/rufus.rb
aeden-moneta-0.6.3 lib/moneta/rufus.rb
benschwarz-moneta-0.6.1 lib/moneta/rufus.rb
benschwarz-smoke-0.5.0 vendor/moneta/lib/moneta/rufus.rb
benschwarz-smoke-0.5.1 vendor/moneta/lib/moneta/rufus.rb
benschwarz-smoke-0.5.2 vendor/moneta/lib/moneta/rufus.rb
benschwarz-smoke-0.5.3 vendor/moneta/lib/moneta/rufus.rb
benschwarz-smoke-0.5.4 vendor/moneta/lib/moneta/rufus.rb
benschwarz-smoke-0.5.5 vendor/moneta/lib/moneta/rufus.rb
benschwarz-smoke-0.5.6 vendor/moneta/lib/moneta/rufus.rb
jferris-moneta-0.6.2 lib/moneta/rufus.rb
jsl-moneta-0.6.1 lib/moneta/rufus.rb
smurphy-moneta-0.6.0 lib/moneta/rufus.rb
gotime-moneta-0.6.2 lib/moneta/rufus.rb
thoughtless-moneta-0.6.0.1 lib/moneta/rufus.rb
moneta-0.6.0 lib/moneta/rufus.rb