| OpenPlugin documentation | view source | Contained in the OpenPlugin distribution. |
OpenPlugin::Cache - Base class for putting data in and getting information out of a cache
use OpenPlugin(); $OP = OpenPlugin->new(); my $id = $OP->cache->save( $large_data_set ); ... my $data = $OP->cache->fetch( $id );
This plugin is designed to save data to a cache, and later retrieve that information from that cache. It is very similar to sessions, but data which is cached is meant for all users. Session data is only meant for the user associated with that particular session.
Data you'd typically want to cache includes information returned which requires a lot of time or processing to retrieve. One example is large database queries.
fetch( $id )
Retrieves whatever is in the cache tagged by $id.
save( $data, { id = $id, expires => $date })>
Saves data into the cache.
Returns: the cache ID used on success, undef on failure.
Basic parameters -- drivers may define others:
"now" - expire immediately "+180s - in 180 seconds "+2m" - in 2 minutes "+12h" - in 12 hours "+1d" - in 1 day "+3M" - in 3 months "+2y" - in 2 years "-3m" - 3 minutes ago(!)
delete( $id )
Delete an existing item from the cache.
Returns true if successful.
None known.
See the TO DO list in the OpenPlugin::Session plugin.
Copyright (c) 2001-2003 Eric Andreychek. All rights reserved.
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
Eric Andreychek <eric@openthought.net>
| OpenPlugin documentation | view source | Contained in the OpenPlugin distribution. |