instance method replace

Ruby on Rails 2.3.18

Since v2.3.18 Last seen in v2.3.18

Signature

replace(key, value, expiry = 0, raw = false)

Add key to the cache with value value that expires in expiry seconds, but only if key already exists in the cache. If raw is true, value will not be Marshalled.

Parameters

key req
value req
expiry opt = 0
raw opt = false
Source
# File activesupport/lib/active_support/vendor/memcache-client-1.7.4/memcache.rb, line 414
  def replace(key, value, expiry = 0, raw = false)
    raise MemCacheError, "Update of readonly cache" if @readonly
    with_server(key) do |server, cache_key|
      value = Marshal.dump value unless raw
      logger.debug { "replace #{key} to #{server}: #{value ? value.to_s.size : 'nil'}" } if logger
      command = "replace #{cache_key} 0 #{expiry} #{value.to_s.size}#{noreply}\r\n#{value}\r\n"

      with_socket_management(server) do |socket|
        socket.write command
        break nil if @no_reply
        result = socket.gets
        raise_on_error_response! result
        result
      end
    end
  end

Defined in activesupport/lib/active_support/vendor/memcache-client-1.7.4/memcache.rb line 414 · View on GitHub · Improve this page · Find usages on GitHub

Defined in MemCache

Type at least 2 characters to search.

↑↓ navigate · open · esc close