NAME

WWW::MetaForge::Cache - File-based caching for MetaForge APIs

VERSION

version 0.002

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.

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.

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

Issues

Please report bugs and feature requests on GitHub at https://github.com/Getty/p5-www-metaforge/issues.

IRC

You can reach Getty on irc.perl.org for questions and support.

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.