Module: Memcached::Experimental

Defined in:
lib/memcached/experimental.rb

Instance Method Summary collapse

Instance Method Details

#get_len(bytes, keys) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/memcached/experimental.rb', line 17

def get_len(bytes, keys)
  if keys.is_a? ::Array
    # Multi get
    ret = Lib.memcached_mget_len(@struct, keys, bytes);
    check_return_code(ret, keys)

    hash = {}
    keys.each do
      value, key, flags, ret = Lib.memcached_fetch_rvalue(@struct)
      break if ret == Lib::MEMCACHED_END
      if ret != Lib::MEMCACHED_NOTFOUND
        check_return_code(ret, key)
        # Assign the value
        hash[key] = value
      end
    end
    hash
  else
    # Single get_len
    value, flags, ret = Lib.memcached_get_len_rvalue(@struct, keys, bytes)
    check_return_code(ret, keys)
    value
  end
rescue => e
  tries ||= 0
  raise unless tries < options[:exception_retry_limit] && should_retry(e)
  tries += 1
  retry
end

#touch(key, ttl = @default_ttl) ⇒ Object

TOUCH is used to set a new expiration time for an existing item



5
6
7
8
9
10
11
12
13
14
15
# File 'lib/memcached/experimental.rb', line 5

def touch(key, ttl=@default_ttl)
  check_return_code(
    Lib.memcached_touch(@struct, key, ttl),
    key
  )
rescue => e
  tries ||= 0
  raise unless tries < options[:exception_retry_limit] && should_retry(e)
  tries += 1
  retry
end