python-memcached2 Exceptions

Overview

The classes that throw exceptions all tend to raise exceptions that are children of the MemcachedException. For storage-related exceptions, they are children of StoreException, and for retrieval they are children of RetrieveException.

If you use the exception-exposing interfaces (“Memcache()”), will need to catch these exceptions as part of your code. They are thrown on exceptional conditions, read the description of the exceptions for details on when they may be thrown.

In specific error cases that likely indicate bugs in the python-memcached2 module, or where the server replies with unexpected data, the NotImplementedError is raised. These situations are extremely unusual and almost certainly should be reported to the developers of either this python-memcached2 module or the developers of the memcached server you are using. You probably don’t want to catch these

Exceptions

class memcached2.MemcachedException

Base exception that all other exceptions inherit from. This is never raised directly.

class memcached2.UnknownProtocol

An unknown protocol was specified in the memcached URI. Sublcass of MemcachedException.

class memcached2.InvalidURI

An error was encountered in parsing the server URI. Subclass of MemcachedException.

class memcached2.ServerDisconnect

The connection to the server closed. Subclass of MemcachedException.

class memcached2.NoAvailableServers

There are no servers available to cache on, probably because all are disconnected. This exception typically occurs after the code which would do a reconnection is run. Subclass of MemcachedException.

class memcached2.StoreException

Base class for storage related exceptions. Never raised directly. Subclass of MemcachedException.

class memcached2.MultiStorageException(message=None, results={})

During a SET operation the server returned CLIENT_ERROR. This is probably due to too long of a key being used. Subclass of StoreException.

class memcached2.NotStored

Item was not stored, but not due to an error. Normally means the condition for an “add” or “replace” was not met.. Subclass of StoreException.

class memcached2.CASFailure

Item you are trying to store with a “cas” command has been modified since you last fetched it (result=EXISTS). Subclass of StoreException.

class memcached2.CASRefreshFailure

When trying to refresh a CAS from the memcached, the retrieved value did not match the value sent with the last update. This may happen if another process has updated the value. Subclass of CASFailure.

class memcached2.NotFound

Item you are trying to store with a “cas” command does not exist.. Subclass of StoreException.

class memcached2.NonNumeric

The item you are trying to incr/decr is not numeric.. Subclass of StoreException.

class memcached2.RetrieveException

Base class for retrieve related exceptions. This is never raised directly.. Subclass of MemcachedException.

class memcached2.NoValue

Server has no data associated with this key.. Subclass of RetrieveException.