Sha256: a051472be542f9d6db8897c8755ae93b8452331d584058cda17fa79b74fd8682

Contents?: true

Size: 948 Bytes

Versions: 5

Compression:

Stored size: 948 Bytes

Contents

begin
  require 'memcached'
rescue LoadError
  raise "You must install memecached to use the Memecache cache store backend"
end

module Padrino
  module Cache
    module Store
      class Memcache
        def initialize(*args)
          @backend = Memcached.new(*args)
        rescue
          raise
        end

        def get(key)
          @backend.get(key)
        rescue Memcached::NotFound
          nil
        end

        def set(key, value, opts = nil)
          if opts && opts[:expires_in]
            expires_in = opts[:expires_in].to_i
            expires_in = Time.new.to_i + expires_in if expires_in < EXPIRES_EDGE
            @backend.set(key, value, expires_in)
          else
            @backend.set(key, value)
          end
        end

        def delete(key)
          @backend.delete(key)
        end

        def flush
          @backend.flush
        end
      end # Memcached
    end # Store
  end # Cache
end # Padrino

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
padrino-cache-0.9.24 lib/padrino-cache/store/memcache.rb
padrino-cache-0.9.23 lib/padrino-cache/store/memcache.rb
padrino-cache-0.9.22 lib/padrino-cache/store/memcache.rb
padrino-cache-0.9.21 lib/padrino-cache/store/memcache.rb
padrino-cache-0.9.20 lib/padrino-cache/store/memcache.rb