public Method

MemCache.delete(key, expiry = 0)

Removes key from the cache in expiry seconds.

Source Code

# File active_support/vendor/memcache-client-1.5.0/memcache.rb, line 377
def delete(key, expiry = 0)
  @mutex.lock if @multithread

  raise MemCacheError, "No active servers" unless active?
  cache_key = make_cache_key key
  server = get_server_for_key cache_key

  sock = server.socket
  raise MemCacheError, "No connection to server" if sock.nil?

  begin
    sock.write "delete #{cache_key} #{expiry}\r\n"
    result = sock.gets
    raise_on_error_response! result
    result
  rescue SocketError, SystemCallError, IOError => err
    server.close
    raise MemCacheError, err.message
  end
ensure
  @mutex.unlock if @multithread
end
Comments

Have your say
Please use Textile formatting (click here for a cheat sheet). Use <code/> and <pre/> for code samples.
Click here to login with OpenID to to post comments.