Sha256: b5f165d127af214f903042407d9fec8d08a96230ef27b3acb5625a889fdada2d

Contents?: true

Size: 1.08 KB

Versions: 18

Compression:

Stored size: 1.08 KB

Contents

begin
  require "localmemcache"
rescue LoadError
  puts "You need the localmemcache gem to use the LMC moneta store"
  exit
end

module Moneta
  class Expiration
    def initialize(hash)
      @hash = hash
    end
    
    def [](key)         @hash["#{key}__!__expiration"]          end
    def []=(key, value) @hash["#{key}__!__expiration"] = value  end
      
    def delete(key)
      key = "#{key}__!__expiration"
      value = @hash[key]
      @hash.delete(key)
      value
    end
  end
  
  class LMC
    include Defaults

    module Implementation
      def initialize(options = {})
        @hash = LocalMemCache.new(:filename => options[:filename])
        @expiration = Expiration.new(@hash)
      end    

      def [](key)         @hash[key]          end
      def []=(key, value) @hash[key] = value  end
      def clear()         @hash.clear         end

      def key?(key)
        @hash.keys.include?(key)
      end

      def delete(key)
        value = @hash[key]
        @hash.delete(key)
        value
      end      
    end
    include Implementation
    include StringExpires
   
  end
end

Version data entries

18 entries across 18 versions & 9 rubygems

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