Nate Lewis


FWS::V2::Cache - Framework Sites version 2 data caching


Version 1.13091122


        use FWS::V2;
        my $fws = FWS::V2->new();

        my $cacheData = $fws->cacheValue( 'someData' ) || &{ sub {
            my $value = 'This is a testineeg!';
            # do something...
            return $fws->saveCache( key => 'someData', expire => 1, value => $value );
        } };

        print $cacheData;
        $fws->deleteCache( key => 'someData' );


FWS version 2 cache methods are used as a portable non-environment specific cache library to the FWS data model. For maximum compatibility it uses the file FWSCache directory under the sites fileSecurePath directory to store its data and is compatible with NFS or other distributed file systems.



Save data to cache passing they key, value and expire (in minutes). The return will be the string passed as value.

    # Save my data to cache and hang on to it for 5 minutes before getting a new a new one
        # but return the current one if my 5 minutes isn't up
    $someValue  = $fws->saveCache( key => 'someData', value => $someValue, expire => 5 );


Remove a key from cache. For optmization, this does not look up the key, only blindly remove it.

    # We no longer need somData lets get rid of it
    $fws->deleteCache( key => 'someData' );


If anything is in cache currently, after this call it won't be!

    # Remove all cache keys


Removes all files located in your web cache. These are the files that are your combined js, and css files created on the fly when pages are rendered. When pages are loaded after this is ran, it will start to repopulate the cache with newly created web cache files.

    # Remove all web cache files


Return the cache value. If the cache value does not exist, it will return blank in same way that formValue, siteValue and userValue.

    # will return the cache value.   This or a blank string if it is not set, or blank
    print $fws->caheValue( 'someData' );


Used internally to craete combined head css and js cached files so they can be used on the page.


Nate Lewis, <nlewis at>


Please report any bugs or feature requests to bug-fws-v2 at, or through the web interface at I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.


You can find documentation for this module with the perldoc command.

    perldoc FWS::V2::Cache

You can also look for information at:


Copyright 2013 Nate Lewis.

This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License.

See for more information.