Class: Memcached::Rails

A legacy compatibility wrapper for the Memcached class. It has basic compatibility with the memcache-client API.

Constants

NameValue
DEFAULTS {}

Public Class Methods


new (servers, opts = {})

See Memcached#new for details.

    # File lib/memcached/rails.rb, line 12
12:     def initialize(servers, opts = {})
13:       super(servers, DEFAULTS.merge(opts))      
14:     end

Public Instance Methods


[] (key)

Alias for get.

    # File lib/memcached/rails.rb, line 45
45:     def [](key)
46:       get key
47:     end

[]= (key, value)

Alias for Memcached#set.

    # File lib/memcached/rails.rb, line 50
50:     def []=(key, value)
51:       set key, value
52:     end

delete (key)

Wraps Memcached#delete so that it doesn‘t raise.

    # File lib/memcached/rails.rb, line 34
34:     def delete(key)
35:       super(key)
36:     rescue NotFound
37:     end

get (key, raw = false)

Wraps Memcached#get so that it doesn‘t raise. This has the side-effect of preventing you from storing nil values.

    # File lib/memcached/rails.rb, line 18
18:     def get(key, raw = false)
19:       super(key, !raw)
20:     rescue NotFound
21:     end

get_multi (*keys)

Wraps Memcached#get with multiple arguments.

    # File lib/memcached/rails.rb, line 24
24:     def get_multi(*keys)
25:       super(keys)
26:     end

namespace ()

Namespace accessor.

    # File lib/memcached/rails.rb, line 40
40:     def namespace
41:       options[:prefix_key]
42:     end

set (key, value, ttl = 0, raw = false)

Wraps Memcached#set.

    # File lib/memcached/rails.rb, line 29
29:     def set(key, value, ttl = 0, raw = false)
30:       super(key, value, ttl, !raw)
31:     end