NAME

CacheFile - Manager for Simple Cache Files

AUTHOR

Shane P. McCarron <shane@aptest.com>

COPYRIGHT

Copyright 2002-2011 Applied Testing and Technology, Inc. All Rights Reserved.

SYNOPSIS

use CacheFile;

    Open the cache Database for writing
    my $db = new CacheFile(suite, name, 1);

    get a handle to the whole requirements database
    $data = $db->allEntries();

    get a handle to a specific cache entry
    $data = $db->entry(name)

    release the database
    $db-E<gt>release();

The CacheFile object is a generic multi-level data structure storage facility. The data stored in this facility is keyed by the pathname associated with each requirement.

DATA STRUCTURE

lock

a handle to the lock that is set for the object

writeable

a boolean that indicates whether the session is open read/write

usingDBM

a boolean to indicate if the file is from a DBM source

data->

a hash of cached data

{data}->{ID}

METHODS

new - open the cache database

$cdb = new CacheFile(suite, name, [read/write [, timeout[, path]]]);

Creates a new cache database object, optionally opening a non-default target file and optionally making it writeable.

suite

Name of the test suite we are operating within.

name

Name of the cache file to open

read/write

boolean set to True if the database needs to be writeable or False if it can be readOnly.

timeout

the number of seconds to wait for a lock. Defaults to 60 seconds.

path

a path to an alternate database (the default is implementation defined).

returns a reference to the requirements database object.

allEntries - retrieve all entries from the cache

$hRef = $cdb->allEntries( [data] ) ;

data is a reference to a hash of data for the cache. If supplied, the entire cache will be replaced with that data.

Returns a reference to a hash in which all the entries from the cache are stored. Note that this is NOT a reference to the tied hash. Data is copied out of the tied hash into memory.

delete - delete an entry

$cdb->delete( entry ) ;

entry - accessor for a specific cache entry

$entryRef = $cdb->entry( name [, data ] ) ;

name is the name of a cache entry.

data is an optional reference to new data for the cached item.

Returns a reference to the data in the cache entry. If data is supplied, first updates the cache entry with that data.

initialize - reset the database file.

Removes all entries from the cache file - should have a Lock before calling this.

returns true if it succeeded, false if it did not.

numEntries - return the number of entries in the cache

$numEntries = $cdb->numEntries;

path - get/set the path to the cache file

returns a path to the cache file.

print - print the contents of the database

$rdb->print();
    $rdb->print(UUID);

returns the string-ified version of the entire database, or just the contents of the requirement UUID.

release - release the database

$cdb->release() ;

save - save the database

returns the path saved into, or undef if the save failed.

Copyright © 2000-2013 Applied Testing and Technology, Inc. All rights reserved.