Alzabo::ObjectCache::Sync - Base class for syncing classes |
Alzabo::ObjectCache::Sync - Base class for syncing classes
package Alzabo::ObjectCache::TelepathySync; use base qw( Alzabo::ObjectCache::Sync );
This class implements most of the logic needed for syncing operations. Subclasses only need to implement methods for actually storing and retrieving the refresh times for an object.
A new cache object.
The object if it is in the cache. Otherwise it returns undef.
Stores an object in the cache. This will not overwrite an existing
object in the cache. To do that you must first call the
delete_from_cache
method.
An object is expired when the local copy's last retrieval of its data
occurred before another copy (in another process, presumably) updated
the external data source containing the object's data (such as an
RDBMS). Note that a deleted object will not be reported as expired.
Instead, call the is_deleted
method.
A boolean value indicating whether or not the object is expired.
A boolean value indicating whether or not an object has been deleted from the cache.
This tells the cache that an object considers its internal data to be up to date with whatever external source it needs to be up to date with.
This tells the cache that an object has updated its external data source. This means that objects in other processes now become expired.
This tells the cache that the object has been removed from its
external data source. This causes the cache to remove the object
internally. Future calls to
is_deleted
in any
process for this object will now return true.
This method allows you to remove an object from the cache. This does
not register the object as deleted. It is provided solely so that you
can call store_object
after calling this method and have
store_object
actually store the new object.
The following methods should be implemented in a subclass.
This method will be called when the object is first created. If not implemented then it will be a noop.
Returns the time that the object matching the given id was last refreshed.
This is called to update the state of the syncing object in regards to a particularl object. The first parameter is the object's id. The second is the time that the object was last refreshed. The third parameter, which is optional, tells the syncing object whether or not to preserve an existing time for the object if it already has one.
Dave Rolsky, <autarch@urth.org>
Alzabo::ObjectCache::Sync - Base class for syncing classes |