{
    "mode": "perldoc",
    "parameter": "Cache::File::Heap",
    "section": "",
    "url": "https://www.chedong.com/phpMan.php/perldoc/Cache%3A%3AFile%3A%3AHeap/json",
    "generated": "2026-10-08T09:12:46Z",
    "synopsis": "use Cache::File::Heap;\n$heap = Cache::File::Heap->new('/path/to/some/heap/file');\n$heap->add($key, $val);\n($key, $val) = $heap->minimum;\n($key, $val) = $heap->extractminimum;\n$heap->delete($key, $val);",
    "sections": {
        "NAME": {
            "content": "Cache::File::Heap - A file based heap for use by Cache::File\n",
            "subsections": []
        },
        "SYNOPSIS": {
            "content": "use Cache::File::Heap;\n\n$heap = Cache::File::Heap->new('/path/to/some/heap/file');\n$heap->add($key, $val);\n($key, $val) = $heap->minimum;\n($key, $val) = $heap->extractminimum;\n$heap->delete($key, $val);\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "This module is a wrapper around a Berkeley DB using a btree structure to implement a heap. It is\nspecifically for use by Cache::File for storing expiry times (although with a bit of work it\ncould be made more general).\n\nSee LIMITATIONS below.\n",
            "subsections": []
        },
        "CONSTRUCTOR": {
            "content": "my $heap = Cache::File::Heap->new( [$dbfile] );\n\nThe heap constructor takes an optional argument which is the name of the database file to open.\nIf specified, it will attempt to open the database during construction. A new Cache::File::Heap\nblessed reference will be returned, or undef if the open failed.\n",
            "subsections": []
        },
        "METHODS": {
            "content": "$h->open($dbfile)\nOpens the specified database file.\n\n$h->close()\nCloses a previously opened heap database. Note that the database will be automatically\nclosed when the heap reference is destroyed.\n\n$h->add($key, $val)\nAdds a key and value pair to the heap. Currently the key should be a number, whilst the\nvalue may be any scalar. Invokes 'die' on failure (use eval to catch it).\n\n$h->delete($key, $val)\nRemoves a key and value pair from the heap. Returns 1 if the pair was found and removed, or\n0 otherwise.\n\n($key, $val) = $h->minimum()\nIn list context, returns the smallest key and value pair from the heap. In scalar context\nonly the key is returned. Note smallest is defined via a numerical comparison (hence keys\nshould always be numbers).\n\n($key, $vals) = $h->minimumdup()\nIn list context, returns the smallest key and an array reference containing all the values\nfor that key from the heap. In scalar context only the key is returned.\n\n($key, $val) = $h->extractminimum()\nAs for $h->minimum(), but the key and value pair is removed from the heap.\n\n($key, $vals) = $h->extractminimumdup()\nAs for $h->minimumdup(), but all the values are removed from the heap.\n",
            "subsections": []
        },
        "SEE ALSO": {
            "content": "Cache::File\n",
            "subsections": []
        },
        "AUTHOR": {
            "content": "Chris Leishman <chris@leishman.org>\nBased on work by DeWitt Clinton <dewitt@unto.net>\n",
            "subsections": []
        },
        "COPYRIGHT": {
            "content": "Copyright (C) 2003-2006 Chris Leishman.  All Rights Reserved.\n\nThis module is distributed on an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either expressed\nor implied. This program is free software; you can redistribute or modify it under the same\nterms as Perl itself.\n\n$Id: Heap.pm,v 1.6 2006/01/31 15:23:58 caleishm Exp $\n",
            "subsections": []
        }
    },
    "summary": "Cache::File::Heap - A file based heap for use by Cache::File",
    "flags": [],
    "examples": [],
    "see_also": []
}