Sha256: 08496332446a350f070033e0b55b9c45b58eb1befbb69cec076428839e297211

Contents?: true

Size: 1.1 KB

Versions: 16

Compression:

Stored size: 1.1 KB

Contents

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

module Moneta
  class Tyrant < ::Rufus::Tokyo::Tyrant
    include Defaults
    
    module Implementation
      def initialize(options = {})
        host = options[:host]
        port = options[:port]
        super(host, port)
      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
    
    include Implementation
    include Expires
    
    def initialize(options = {})
      super
      @expiration = Expiration.new(options)
    end
    
    class Expiration < ::Rufus::Tokyo::Tyrant
      include Implementation
      
      def [](key)
        super("#{key}__expiration")
      end
      
      def []=(key, value)
        super("#{key}__expiration", value)
      end
      
      def delete(key)
        super("#{key}__expiration")
      end
    end
  end  
end

Version data entries

16 entries across 16 versions & 9 rubygems

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