This method controls the expiration of cached objects.
If called with no arguments, the cache expiration limit in seconds is returned. If passed a DURATION, the cache expiration is set. Valid formats for DURATION are in the form NUMBER UNIT where NUMBER is a positive number and UNIT is one of the following:
All formats of the DURATION argument are converted to seconds. Days are exactly 24 hours, weeks are 7 days, and years are 365 days.
If an object was read from the database the specified number of seconds ago or earlier, it is purged from the cache and reloaded from the database the next time it is loaded.
A cached_objects_expire_in value of undef or zero means that nothing will ever expire from the object cache. This is the default.
|<B>clear_object_cacheB>||Clear the memory cache for all objects of this class.|
<B>delete [PARAMS]B> This method works like the delete method from Rose::DB::Object except that it also calls the forget method if the object was deleted successfully or did not exist in the first place. <B>forgetB> Delete the current object from the memory cache. <B>load [PARAMS]B> Load an object based on either a primary key or a unique key.
If the object exists in the memory cache, the current object becomes the cached object. See the synopsis or description above for more information.
If the object is not in the memory cache, it is loaded from the database. If the load succeeds, it is also written to the memory cache.
PARAMS are name/value pairs, and are optional. Valid parameters are:
<B>refreshB> If set to a true value, then the data is always loaded from the database rather than from the memory cache. If the load succeeds, the object replaces whatever was in the cache. If it fails, the cache is not modified.
Returns true if the object was loaded successfully, false if the row could not be loaded or did not exist in the database. The true value returned on success will be the object itself. If the object overloads its boolean value such that it is not true, then a true value will be returned instead of the object itself.
<B>insert [PARAMS]B> This method does the same thing as the Rose::DB::Object method of the same name, except that it also saves the object to the memory cache if the insert succeeds. If it fails, the memory cache is not modified. <B>rememberB> Save the current object to the memory cache without saving it to the database as well. Objects are cached based on their primary key values and all their unique key values. <B>remember_all [PARAMS]B> Load and remember all objects from this table, optionally filtered by PARAMS which can be any valid Rose::DB::Object::Manager->get_objects() parameters. Remembered objects will replace any previously cached objects with the same keys. <B>remember_by_primary_key [PARAMS]B> Save the current object to the memory cache without saving it to the database as well. The object will be cached based on its primary key value only. This is unlike the remeber method which caches objects based on their primary key values and all their unique key values. <B>save [PARAMS]B> This method does the same thing as the Rose::DB::Object method of the same name, except that it also saves the object to the memory cache if the save succeeds. If it fails, the memory cache is not modified. <B>update [PARAMS]B> This method does the same thing as the Rose::DB::Object method of the same name, except that it also saves the object to the memory cache if the update succeeds. If it fails, the memory cache is not modified.
In addition to the reserved methods listed in the Rose::DB::Object documentation, the following method names are also reserved for objects that inherit from this class:
cached_objects_expire_in clear_object_cache forget remember remember_all remember_by_primary_key
If you have a column with one of these names, you must alias it. See the Rose::DB::Object documentation for more information on column aliasing and reserved methods.
John C. Siracusa (firstname.lastname@example.org)
Copyright (c) 2010 by John C. Siracusa. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
|perl v5.20.3||ROSE::DB::OBJECT::CACHED (3)||2015-03-17|