Softpedia
 


LINUX CATEGORIES:



GLOBAL PAGES >>
NEWS ARCHIVE >>
SOFTPEDIA REVIEWS >>
MEET THE EDITORS >>
WEEK'S BEST
  • Linux Kernel 3.9.2 / 3....
  • LibreOffice 3.6.6 / 4.0.3
  • MPlayer 1.1.1
  • systemd 204
  • Arch Linux 2013.05.01
  • Blender 2.67
  • KDE Software Compilatio...
  • CrunchBang Linux Stable...
  • Elementary OS 0.1 / 0.2...
  • SystemRescueCd 3.6.0
  • Home > Linux > Programming > Perl Modules

    Tie::Cacher 0.09

    Download button

    No screenshots available
    Downloads: 505  View global page NEW!  Tell us about an update
    User Rating:
    Rated by:
    Good (3.1/5)
    7 user(s)
    Developer:

    License / Price:

    Last Updated:

    Category:
    Ton Hospel | More programs
    Perl Artistic License / FREE
    July 21st, 2008, 13:18 GMT
    ROOT / Programming / Perl Modules

     Read user reviews (0)  Refer to a friend  Subscribe

    Tie::Cacher description

    Tie::Cacher is a Perl module to cache a (sub)set of key/value pairs. Tie and OO interface.

    Tie::Cacher is a Perl module to cache a (sub)set of key/value pairs. Tie and OO interface.

    SYNOPSIS

    # The Object Oriented interface:
    use Tie::Cacher;
    $cache = Tie::Cacher->new($max_count);
    $cache = Tie::Cacher->new(%options);
    $cache = Tie::Cacher->new(%options);

    $cache->store($key, $value);
    $value = $cache->fetch($key);
    $node = $cache->fetch_node($key);

    $nr_keys = $cache->keys;
    @keys = $cache->keys;
    @keys = $cache->recent_keys;
    @keys = $cache->old_keys;
    $key = $cache->most_recent_key;
    $key = $cache->oldest_key;

    $key = $cache->first_key;
    ($key, $value) = $cache->first_key;
    $key = $cache->next_key;
    ($key, $value) = $cache->next_key;

    $exists = $cache->exists($key);

    $cache->delete(@keys);
    $value = $cache->delete(@keys);
    @values = $cache->delete(@keys);
    $cache->clear;

    $nr_keys = $cache->count;

    $hit = $cache->hit;
    $old_hit = $cache->hit($new_hit);
    $missed = $cache->missed;
    $old_missed = $cache->missed($new_missed);

    $max_count = $cache->max_count;
    $old_max_count = $cache->max_count($new_max_count);
    $validate = $cache->validate;
    $old_validate = $cache->validate($new_validate);
    $load = $cache->load;
    $old_load = $cache->load($new_load);
    $save = $cache->save;
    $old_save = $cache->save($new_save);
    $user_data = $cache->user_data;
    $old_user_data = $cache->user_data($new_user_data);

    # The Tie interface:
    use Tie::Cacher;
    $tied = tie Êche, 'Tie::Cache', $max_count;
    $tied = tie Êche, 'Tie::Cache', %options;
    $tied = tie Êche, 'Tie::Cache', {%options};

    # cache supports normal tied hash functions
    $cache{1} = 2; # STORE
    print "$cache{1}n"; # FETCH

    print "Yesn" if exists $cache{1}; # EXISTS
    @keys = keys Êche; # KEYS

    # FIRSTKEY, NEXTKEY
    while(($k, $v) = each Êche) { print "$k: $vn"; }

    delete $cache{1}; # DELETE
    Êche = (); # CLEAR

    # Or use the OO methods on the underlying tied object:
    print $tied->max_count, "n";

    This module implements a least recently used (LRU) cache in memory through a tie and a OO interface. Any time a key/value pair is fetched or stored, an entry time is associated with it, and as the cache fills up, those members of the cache that are the oldest are removed to make room for new entries.

    So, the cache only "remembers" the last written entries, up to the size of the cache. This can be especially useful if you access great amounts of data, but only access a minority of the data a majority of the time.

    The implementation is a hash, for quick lookups, overlaying a doubly linked list for quick insertion and deletion. Notice that the OO interface will be faster than the tie interface.

    Product's homepage

    Requirements:

    · Perl

      


    TAGS:

    value pairs | Tie interface | Perl module | value | pairs | Tie

    Go to top

    WindowsGamesDriversMacLinuxScriptsMobileHandheldNews

    SUBMIT PROGRAM   |   ADVERTISE   |   GET HELP   |   SEND US FEEDBACK   |   RSS FEEDS   |   UPDATE YOUR SOFTWARE   |   ROMANIAN FORUM