NAME
WWW::MetaForge::Cache - File-based caching for MetaForge APIs
VERSION
version 0.001
SYNOPSIS
use WWW::MetaForge::Cache;
my $cache = WWW::MetaForge::Cache->new;
my $data = $cache->get('items', { search => 'Ferro' });
$cache->set('items', { search => 'Ferro' }, $response_data);
$cache->clear('items');
DESCRIPTION
File-based caching for MetaForge API responses. Cache files are stored following XDG Base Directory Specification on Unix (~/.cache/metaforge/) and LOCALAPPDATA on Windows.
ATTRIBUTES
namespace
Directory name for cache. Defaults to metaforge.
cache_dir
Path::Tiny object for cache directory. Auto-detected based on OS. Accepts string (coerced to Path::Tiny).
ttl
HashRef of TTL values per endpoint in seconds. Default is empty (cache never expires). Use 0 or undef for infinite TTL.
Example with expiration:
my $cache = WWW::MetaForge::Cache->new(
ttl => { event_timers => 300 } # 5 minutes for events only
);
json
JSON::MaybeXS instance for serialization.
METHODS
get
my $data = $cache->get($endpoint, \%params);
Returns cached data or undef if missing/expired.
set
$cache->set($endpoint, \%params, $data);
Store data in cache with timestamp.
clear
$cache->clear('items'); # Clear specific endpoint
$cache->clear; # Clear all
Remove cached files.
clear_all
Alias for $cache->clear.
SUPPORT
Source Code
The code is open to the world, and available for you to hack on. Please feel free to browse it and play with it, or whatever. If you want to contribute patches, please send me a diff or prod me to pull from your repository :)
https://github.com/Getty/p5-www-metaforge
git clone https://github.com/Getty/p5-www-metaforge.git
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.