Konstantin Stepanov


FusqlFS::Cache::Base - base abstract class for cache strategy classes implementation


    package FusqlFS::Cache::CleverStrategy;
    use parent 'FusqlFS::Cache::Base';

    sub TIEHASH
        # ...

    sub FETCH
        # ...

    sub STORE
        # ...


This is an abstract base class for all cache strategy subclasses.

FusqlFS cache is a hash. To implement any cache strategy you need to create a hash tie()-able class (see also perltie for more info) which will be tied to cache hash and should implement cache strategy you want.

This class defines main cache class interface. See "METHODS" section for details on this interface.



Class constructor (so called).

Input: @parameters. Output: $cache_hashref.

This method is not a real constructor, it's actually a tie()-er.

It creates new empty hash, checks if given parameters satisfy this concrete class implementation and tie()s hash to this class if everything ok.

The returned value is a hashref tied to the class (or untied if parameters don't satisfy class's requirements). See also "is_needed" method to learn how criteria for correct cache parameters are defined.


Abstract method called to determine if cache parameters satisfy this cache strategy's criteria.

Input: @parameters. Output: $satisfied.

This method is called before the class is tied to real cache hash to determine if cache strategy implemented by the class can be used with given parameters.

The method is passed the same parameters, as "new" method, and must return boolean value: true if these parameters have sense for the cache strategy or false otherwise.

If this method returns false no cache class instance is created nor tied to cache hash, so cache strategy is fallen back to `memory'.

See also FusqlFS::Cache for more info about cache strategies initialization.