Apache::Cache

Apache::Cache is a cache data accessible between Apache childrens.
Download

Apache::Cache Ranking & Summary

Advertisement

  • Rating:
  • License:
  • Perl Artistic License
  • Price:
  • FREE
  • Publisher Name:
  • Olivier Poitrey
  • Publisher web site:
  • http://search.cpan.org/~rsoliv/Apache-SharedMem-0.09/lib/Apache/SharedMem.pm

Apache::Cache Tags


Apache::Cache Description

Apache::Cache is a cache data accessible between Apache childrens. Apache::Cache is a cache data accessible between Apache childrens.SYNOPSIS use Apache::Cache qw(:status); my $cache = new Apache::Cache(default_expires_in=>"5 minutes"); # if the if the next line is called within 10 minutes, then this # will return the cache value overwise, this will return undef and the # status method will be equal to the constant EXPIRED (exported by Apache::Cache # on demande via the :status tag) # the next line try to get the data from the cache, if the data is stored in # in the cache and if it not expired, then this return the data. Otherwise # if data have never been store in the cache, or if it's expired, this will # return undef and the status() method will be equal to constant EXPIRED (exported # by Apache::Cache on demand, via the :status tag) my $value = $cache->get('Key'); if($cache->status eq EXPIRED) { # can't get the data from the cache, we will need to get it by the normal way # (via database, from file...) $value = get_my_data('Key'); # here, the get_my_data() function is a function of your # programe that generate a fresh value # this data have to expires in 30 secondes my $expires_in = '30 secondes'; $cache->set(Key => $value, $expires_in); } elsif($cache->status eq FAILURE) { # don't use cache, cache maybe busy by another child or something goes wrong $value = get_my_data('Key'); }This module allows you to cache data easily through shared memory. Whithin the framework of an apache/mod_perl use, this cache is accessible from any child process. The data validity is managed in the Cache::Cache model, but as well based on time than on size or number of keys.Additionnally, you can implement a cache with Apache::Cache in your module without the risk of namespace clash because Apache::Cache is enclosed in the constructor's package's caller (see Apache::SharedMem for more details). Requirements: · Perl


Apache::Cache Related Software