Catman...ex::Map(3pm)
π NAME π
Catmandu::DirectoryIndex::Map β she translates between id and path using a Catmandu::Bag as her lookup table β¨
(also bestie this is a 3pm page, i.e. a Perl module doc from the User Contributed Perl Documentation, so you know it's the good stuff π«Ά)
πΈ SYNOPSIS πΈ
use Catmandu::DirectoryIndex::Map;
use Catmandu::Store::DBI;
# Bag to store/retrieve all path -> directory mapping
my $bag = Catmandu::Store::DBI->new(
data_source => "dbi:sqlite:dbname=/data/index.db"
)->bag("paths");
my $p = Catmandu::DirectoryIndex::Map->new(
base_dir => "/data",
bag => $bag
);
# Tries to find a mapping for id "a".
# return: mapping or undef
my $mapping = $p->get("a");
# Returns a mapping like { _id => "a", _path => "/data/2018/01/01/16/00/00/0cc175b9c0f1b6a831c399e269772661" }
my $mapping = $p->add("a");
# Catmandu::DirectoryIndex::Map is a Catmandu::Iterable
# Returns list of records: [{ _id => "a", _path => "/data/2018/01/01/16/00/00/0cc175b9c0f1b6a831c399e269772661" }]
my $mappings = $p->to_array();
π¦ DESCRIPTION π¦
okay so this package uses a Catmandu::Bag backend to translate between ids and paths. that's the whole vibe π
Every record looks like this, no cap:
{ _id => "a", _path => "/data/2018/01/01/16/00/00/0cc175b9c0f1b6a831c399e269772661" }
If the mapping for the id doesn't exist yet, this package just calculates it by concatenating into a path:
$base_dirwhich is configurable πYYYY: current yearMM: current monthDD: current day of monthHH: current hourMM: current minuteSS: current secondTEXT: the md5 of the_id
Every call to add will generate a directory entry in the backend database, if it didn't already exist. so it's idempotent-ish bestie, it's not gonna duplicate on you π«Ά
β¨ METHODS β¨
π new( OPTIONS )
Create a new Catmandu::DirectoryIndex::Map with the following configuration parameters:
base_dirβ SeeCatmandu::DirectoryIndexstore_nameβ Name of the store in the Catmandu configuration.
Ignored when bag instance is given.
bag_nameβ Name of the bag in the Catmandu configuration.
Ignored when bag instance is given
bagβ Instance ofCatmandu::Bagwhere all mappings between_idand_pathare stored.
π INHERITED METHODS π
This Catmandu::DirectoryIndex::Map implements:
Catmandu::DirectoryIndex
π SEE ALSO π
Catmandu::DirectoryIndex
and that's the whole page bestie, go forth and map some directories π§π
this was perl v5.36.0, dated 2022-12-10, from the User Contributed Perl Documentation β Catman...ex::Map(3pm) β¨ slay, periodt π
π¦ where this page comes from
- debian bookworm: libcatmandu-filestore-perl 1.16-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libcatmandu-filestore-perl 1.16-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms