NAME

RSSCache::Backend - Base class for all backend implementations

SYNOPSIS

        use RSSCache::Backend;
        @ISA = qw/RSSCache::Backend/;

DESCRIPTION

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.

METHODS

new

Constructor.

You should inherit or call this constructor to set the default settings:

        sub new {
                return bless RSSCache::Backend->new(), $class;
        }

feeds

Returns an array of the URLs of all feeds that are currently cached.

feed_loaded

Returns true if the feed with the specified URL has already been added to the backend store.

Parameters:

feed

Returns the content of one feed specified by its URL.

Parameters:

item_count

Returns the number of items of a specified feed.

Parameters:

feed_error

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.

Parameters:

add_or_update_feed

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.

Parameters:

delete_feed

Deletes the specified feed.

Parameters:

clear

Clears the whole backend cache (i.e. deletes all cached feeds).

parse_feed

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.

Parameters:

configtime_to_unixtime

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.

Parameters:

load_initial_feed

Will download and cache the initial feeds that have been defined in the configuration file.

Will be called on startup.

generate_client_id

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.

client_id_exists

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".

Parameters:

set_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.

Parameters:

store_data

Stores the current date to a persistent medium (e.g. hard disk). Will be called at shutdown. May be scheduled regularly.

AUTHOR

Copyright 2006 Thomas Wittek (mail at gedankenkonstrukt dot de). All rights reserved.

LICENsE

This document is free software. It is distributed under the same terms as Perl itself.

SEE ALSO

RSSCache, RSSCache::Backend::Memory