# ``twisted`.`spread`.`pb`.`RemoteCache``

class documentation

`class RemoteCache(RemoteCopy, Serializable): (source)`

Known subclasses: `twisted.spread.publish.RemotePublished`

View In Hierarchy

A cache is a local representation of a remote `Cacheable` object.

This represents the last known state of this object. It may also have methods invoked on it -- in order to update caches, the cached class generates a `pb.RemoteReference` to this object as it is originally sent.

Much like copy, I will be invoked with no arguments. Do not implement a constructor that requires arguments in one of my subclasses.

Method | `__cmp__` | Compare me [to another RemoteCache.
Method | `__del__` | Do distributed reference counting on finalize.
Method | `__hash__` | Hash me.
Method | `jellyFor` | serialize me (only for the broker I'm for) as the original cached reference
Method | `remoteMessageReceived` | A remote message has been received. Dispatch it appropriately.
Method | `unjellyFor` | Perform the inverse operation of `Jellyable.jellyFor`.
Instance Variable | `__dict__` | Undocumented
Instance Variable | `broker` | Undocumented
Instance Variable | `luid` | Undocumented
Method | `_borgify` | Create a new object that shares its state (i.e. its `__dict__`) and type with this object, but does not share its identity.

Inherited from `RemoteCopy`:

Method | `setCopyableState` | I will be invoked with the state to copy locally.

Inherited from `Unjellyable` (via `RemoteCopy`):

Method | `setStateFor` | Undocumented

Inherited from `Serializable`:

Method | `processUniqueID` | Return an ID which uniquely represents this object for this process.

Inherited from `Jellyable` (via `Serializable`):

Method | `getStateFor` | Undocumented

def __cmp__(self, other): (source)
Compare me [to another RemoteCache.
def __del__(self): (source)
Do distributed reference counting on finalize.
def __hash__(self): (source)
Hash me.
def jellyFor(self, jellier): (source)
from `twisted.spread.interfaces.IJellyable`
overrides `twisted.spread.jelly.Jellyable.jellyFor`
serialize me (only for the broker I'm for) as the original cached reference
def remoteMessageReceived(self, broker, message, args, kw): (source)

A remote message has been received. Dispatch it appropriately.

The default implementation is to dispatch to a method called '`observe_messagename`' and call it on my with the same arguments.

def unjellyFor(self, unjellier, jellyList): (source)
from `twisted.spread.interfaces.IUnjellyable`
overrides `twisted.spread.pb.RemoteCopy.unjellyFor`
Perform the inverse operation of `Jellyable.jellyFor`.

See Also
`twisted.spread.interfaces.IUnjellyable.unjellyFor`

__dict__ = (source)
overrides `twisted.spread.pb.RemoteCopy.__dict__`

Undocumented

broker = (source)

Undocumented

luid = (source)

Undocumented

def _borgify(self): (source)

Create a new object that shares its state (i.e. its `__dict__`) and type with this object, but does not share its identity.

This is an instance of the Borg design pattern originally described by Alex Martelli, but unlike the example given there, this is not a replacement for a Singleton. Instead, it is for lifecycle tracking (and distributed garbage collection). The purpose of these separate objects is to have a separate object tracking each application-level reference to the root `RemoteCache` object being tracked by the broker, and to have their `__del__` methods be invoked.

This may be achievable via a weak value dictionary to track the root `RemoteCache` instances instead, but this implementation strategy predates the availability of weak references in Python.

Returns
`self.__class__` | The new instance.