info > Cache::Entry

📄 NAME

Cache::Entry – interface for a cache entry

🚀 Quick Reference

Use CaseCommandDescription
Get entry from cache$entry = $cache->entry($key)Create or retrieve a cache entry object
Check existence$entry->exists()Returns true if data is cached for this entry
Read data$entry->get()Retrieve cached data (or undef if missing)
Write data$entry->set($data, $expiry)Store data with optional expiry time
Remove entry$entry->remove()Clear cached data for this entry
Get expiry time$entry->expiry()Returns expiry time in seconds since epoch
Set expiry time$entry->set_expiry($time)Set expiry as absolute time or relative string
Open filehandle$entry->handle($mode, $expiry)Get an IO::Handle for reading/writing large data
Store complex objects$entry->freeze($data, $expiry)Serialize any complex data via Storable
Retrieve complex objects$entry->thaw()Deserialize data previously stored with freeze

đŸ’ģ SYNOPSIS

  my $entry = $cache->entry( $key )
  my $data;
  if ($entry->exists()) {
      $data = $entry->get();
  }
  else {
      $data = get_some_data($key);
      $entry->set($data, '10 minutes');
  }

📖 DESCRIPTION

Objects derived from Cache::Entry represent an entry in a Cache. Methods are provided that act upon the data in the entry, and allow you to set things like the expiry time.

Users should not create instances of Cache::Entry directly, but instead use the entry($key) method of a Cache instance.

đŸ› ī¸ METHODS

🧩 STORING VALIDITY OBJECTS

There are two additional set & get methods that can be used to store a validity object that is associated with the data in question. Typically this is useful in conjunction with a validate_callback, and may be used to store a timestamp or similar to validate against. The validity data stored may be any complex data that can be serialized via Storable.

đŸ—„ī¸ STORING COMPLEX OBJECTS

The set and get methods only allow for working with simple scalar types, but if you want to store more complex types they need to be serialized first. To assist with this, the freeze and thaw methods are provided. They are simple wrappers to get & set that use Storable to do the serialization and de-serialization of the data.

Note: You must be careful to ONLY use thaw on data that was stored via freeze. Otherwise the stored data won't actually be in Storable format and it will complain loudly.

🔗 SEE ALSO

👤 AUTHOR

Chris Leishman <chris AT leishman.org>
Based on work by DeWitt Clinton <dewitt AT unto.net>

ÂŠī¸ COPYRIGHT

Copyright (C) 2003-2006 Chris Leishman. All Rights Reserved.

This module is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either expressed or implied. This program is free software; you can redistribute or modify it under the same terms as Perl itself.

$Id: Entry.pm,v 1.8 2006/01/31 15:23:58 caleishm Exp $

Cache::Entry
📄 NAME 🚀 Quick Reference đŸ’ģ SYNOPSIS 📖 DESCRIPTION đŸ› ī¸ METHODS 🧩 STORING VALIDITY OBJECTS đŸ—„ī¸ STORING COMPLEX OBJECTS 🔗 SEE ALSO 👤 AUTHOR ÂŠī¸ COPYRIGHT

Generated by phpman v4.9.26-5-g7740029 Author: Che Dong Under GNU General Public License
2026-08-14 21:50 @2600:1f28:365:80b0:4d23:66fa:c2bb:7bae
CrawledBy CCBot/2.0 (https://commoncrawl.org/faq/)
Valid XHTML 1.0 Transitional!Valid CSS!