NAME
WWW::Bund::Cache - GET response caching on disk
VERSION
version 0.001
SYNOPSIS
use WWW::Bund::Cache;
my $cache = WWW::Bund::Cache->new(
cache_dir => '/path/to/cache',
ttl => 3600, # default TTL in seconds
);
# Store response
$cache->set($cache_key, $content);
# Retrieve cached response
my $content = $cache->get($cache_key);
my $content = $cache->get($cache_key, 300); # override TTL
# Clear all cache
$cache->clear;
DESCRIPTION
Disk-based cache for HTTP GET responses. Cache files are stored under cache_dir/responses/ with MD5-hashed filenames. Each cached item has a TTL (time-to-live) and is automatically invalidated when expired.
UTF-8 content is properly encoded as bytes before writing to disk.
cache_dir
Base directory for cache storage. Required.
Cache files are written to cache_dir/responses/.
ttl
Default time-to-live in seconds for cached items. Defaults to 3600 (1 hour).
Can be overridden per-call in get.
get
my $content = $cache->get($key);
my $content = $cache->get($key, $ttl_override);
Retrieve cached content by key. Returns undef if not cached or expired.
The optional $ttl_override parameter overrides the default TTL for this lookup.
set
$cache->set($key, $content);
Store content in cache. If $content is a UTF-8 character string, it is automatically encoded to bytes before writing.
clear
$cache->clear;
Delete all cached files from cache_dir/responses/.
SUPPORT
Issues
Please report bugs and feature requests on GitHub at https://github.com/Getty/p5-www-bund/issues.
CONTRIBUTING
Contributions are welcome! Please fork the repository and submit a pull request.
AUTHOR
Torsten Raudssus <torsten@raudssus.de>
COPYRIGHT AND LICENSE
This software is copyright (c) 2026 by Torsten Raudssus.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.