RSSCache::Backend - Base class for all backend implementations
use RSSCache::Backend; @ISA = qw/RSSCache::Backend/;
This is the base class for all backend implementation classes.
Currently there exists only one backend implementation (RSSCache::Backend::Memory) but it may be followed by others (like DBI).
When creating an own backend implementation, you must overwrite the methods of this base class, that will print out an error message otherwise.
Constructor.
You should inherit or call this constructor to set the default settings:
sub new { return bless RSSCache::Backend->new(), $class; }
Returns an array of the URLs of all feeds that are currently cached.
Returns true if the feed with the specified URL has already been added to the backend store.
Returns the content of one feed specified by its URL.
If defined, your backend implementation should only return the feed items that the client hasn't downloaded yet. So your backend has to save the date of the last download for each CID and should only return the feed items younger than this date. If there are no new feeds, your implementation should/may return an empty string to save even more traffic.
Unless defined (e.g. = undef) your implementation should return the whole feed.
Returns the number of items of a specified feed.
Will be called by the feed poller when a feed couldn't be downloaded.
The backend implementation might store the date of the last successful download and remove a feed from the cache if the last successful download was a too long time ago when an error occurs.
Will add or update a feed specified by its URL and its current content.
Within this method the backend implementation should add a new feed/new items to its cache. You might want to use "parse_feed" to parse the feed content.
This method will be called by the RSSCache::Poller.
Deletes the specified feed.
Clears the whole backend cache (i.e. deletes all cached feeds).
Parses a given feed and returns an hashref:
{ start => 'eveything before the first item', end => 'everything after the last item', items => [ '<item> ... </item>', ... ] }
Can handle RSS, RDF and Atom feeds.
Converts a duration definition in the format "1y 2m 3d" (= 1 year, 2 months, 3 days) into seconds and returns it.
This is useful when you want to allow the user to define durations within the config file.
Will download and cache the initial feeds that have been defined in the configuration file.
Will be called on startup.
Generates and returns an unique 8 char ([a-zA-Z0-6]) long client ID.
Your backend implementation doesn't have to overwrite this method, so it might be inherited.
Returns true, if a given client id (CID) exists.
Will be used by the method generate_client_id to avoid creating the same CID twice.
See also "create_client_id".
Adds a new client id (CID) to the data store.
Will be called by "generate_client_id" right after a new CID has been created.
The CID has to be stored explicitly to avoid creating the same CID twice.
Stores the current date to a persistent medium (e.g. hard disk). Will be called at shutdown. May be scheduled regularly.
Copyright 2006 Thomas Wittek (mail at gedankenkonstrukt dot de). All rights reserved.
This document is free software. It is distributed under the same terms as Perl itself.