Cache:...e::Heap(3pm)
π Cache::File::Heap β from the User Contributed Perl Documentation π
okay bestie, welcome to the little page that could: Cache::File::Heap, living its best life in section 3pm of the perl docs β¨
π¦ NAME π¦
Cache::File::Heap β a file based heap for use by Cache::File π
πΈ SYNOPSIS πΈ
no cap, this is literally the whole vibe:
use Cache::File::Heap;
$heap = Cache::File::Heap->new('/path/to/some/heap/file');
$heap->add($key, $val);
($key, $val) = $heap->minimum;
($key, $val) = $heap->extract_minimum;
$heap->delete($key, $val);
β¨ DESCRIPTION β¨
So this module is a wrapper around a Berkeley DB that uses a btree structure to implement a heap. It's specifically for use by Cache::File to store expiry times β though the docs say with a bit of work it could be made more general. so like, main character energy but with a very specific job rn πββοΈ
π«Ά See LIMITATIONS below. (it's a heading that's promised, and we keep the promise, iykyk)
π CONSTRUCTOR π
my $heap = Cache::File::Heap->new( [$dbfile] );
The heap constructor takes an optional argument which is the name of the database file to open. If you specify it, it will attempt to open the database during construction. You get back a brand new Cache::File::Heap blessed reference β or undef if the open failed π (rip, but at least it's honest).
π METHODS π
$h->open($dbfile)β Opens the specified database file. simple as that, periodt.$h->close()β Closes a previously opened heap database. Note that the database will be automatically closed when the heap reference is destroyed β so she cleans up after herself, iconic.$h->add($key, $val)β Adds a key and value pair to the heap. Currently the key should be a number, whilst the value may be any scalar. Invokes'die'on failure β so useevalto catch it, bestie, don't let it take you out π$h->delete($key, $val)β Removes a key and value pair from the heap. Returns1if the pair was found and removed, or0otherwise.($key, $val) = $h->minimum()β In list context, returns the smallest key and value pair from the heap. In scalar context only the key is returned. Note that smallest is defined via a numerical comparison β hence keys should always be numbers. fr fr.($key, $vals) = $h->minimum_dup()β In list context, returns the smallest key and an array reference containing all the values for that key from the heap. In scalar context only the key is returned.($key, $val) = $h->extract_minimum()β As for$h->minimum(), but the key and value pair is removed from the heap. bye bestie π($key, $vals) = $h->extract_minimum_dup()β As for$h->minimum_dup(), but all the values are removed from the heap. not a single one left behind.
π SEE ALSO π
Cache::File
π AUTHOR π
Chris Leishman <chris@leishman.org>
Based on work by DeWitt Clinton <dewitt@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: Heap.pm,v 1.6 2006/01/31 15:23:58 caleishm Exp $
and that's the whole page, bestie β slay π β¨
This one came to you via perl v5.34.0, dated 2022-06-09, straight out of Cache:...e::Heap(3pm) β go forth and heap responsibly, queen ππ¦πΈ
π¦ where this page comes from
- debian bookworm: libcache-perl 2.11-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- debian trixie: libcache-perl 2.11-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libcache-perl 2.11-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libcache-perl 2.11-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libcache-perl 2.11-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