{
    "content": [
        {
            "type": "text",
            "text": "# LWP::ConnCache (info)\n\n## NAME\n\nLWP::ConnCache - Connection cache manager\n\n## SYNOPSIS\n\nuse LWP::ConnCache;\nmy $cache = LWP::ConnCache->new;\n$cache->deposit($type, $key, $sock);\n$sock = $cache->withdraw($type, $key);\n\n## DESCRIPTION\n\nThe \"LWP::ConnCache\" class is the standard connection cache manager for\nLWP::UserAgent.\n\n## Sections\n\n- **NAME**\n- **NOTE**\n- **SYNOPSIS**\n- **DESCRIPTION**\n- **METHODS**\n- **PROTOCOL METHODS**\n- **INTERNAL METHODS**\n- **SUBCLASSING**\n- **SEE ALSO**\n- **COPYRIGHT**\n\nUse structuredContent.sections for detailed options, examples, and full documentation.\n"
        }
    ],
    "structuredContent": {
        "command": "LWP::ConnCache",
        "section": "",
        "mode": "info",
        "summary": "LWP::ConnCache - Connection cache manager",
        "synopsis": "use LWP::ConnCache;\nmy $cache = LWP::ConnCache->new;\n$cache->deposit($type, $key, $sock);\n$sock = $cache->withdraw($type, $key);",
        "tldr_summary": null,
        "tldr_examples": [],
        "tldr_source": null,
        "flags": [],
        "examples": [],
        "see_also": [],
        "section_outline": [
            {
                "name": "NAME",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "NOTE",
                "lines": 3,
                "subsections": []
            },
            {
                "name": "SYNOPSIS",
                "lines": 5,
                "subsections": []
            },
            {
                "name": "DESCRIPTION",
                "lines": 3,
                "subsections": []
            },
            {
                "name": "METHODS",
                "lines": 80,
                "subsections": []
            },
            {
                "name": "PROTOCOL METHODS",
                "lines": 19,
                "subsections": []
            },
            {
                "name": "INTERNAL METHODS",
                "lines": 20,
                "subsections": []
            },
            {
                "name": "SUBCLASSING",
                "lines": 8,
                "subsections": []
            },
            {
                "name": "SEE ALSO",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "COPYRIGHT",
                "lines": 6,
                "subsections": []
            }
        ],
        "sections": {
            "NAME": {
                "content": "LWP::ConnCache - Connection cache manager\n",
                "subsections": []
            },
            "NOTE": {
                "content": "This module is experimental.  Details of its interface is likely to\nchange in the future.\n",
                "subsections": []
            },
            "SYNOPSIS": {
                "content": "use LWP::ConnCache;\nmy $cache = LWP::ConnCache->new;\n$cache->deposit($type, $key, $sock);\n$sock = $cache->withdraw($type, $key);\n",
                "subsections": []
            },
            "DESCRIPTION": {
                "content": "The \"LWP::ConnCache\" class is the standard connection cache manager for\nLWP::UserAgent.\n",
                "subsections": []
            },
            "METHODS": {
                "content": "The following basic methods are provided:\n\nnew\nmy $cache = LWP::ConnCache->new( %options )\n\nThis method constructs a new LWP::ConnCache object.  The only option\ncurrently accepted is \"totalcapacity\".  If specified it initializes\nthe \"totalcapacity\" in LWP::ConnCache option. It defaults to 1.\n\ntotalcapacity\nmy $cap = $cache->totalcapacity;\n$cache->totalcapacity(0); # drop all immediately\n$cache->totalcapacity(undef); # no limit\n$cache->totalcapacity($number);\n\nGet/sets the number of connection that will be cached.  Connections\nwill start to be dropped when this limit is reached.  If set to 0, then\nall connections are immediately dropped.  If set to \"undef\", then there\nis no limit.\n\ncapacity\nmy $httpcapacity = $cache->capacity('http');\n$cache->capacity('http', 2 );\n\nGet/set a limit for the number of connections of the specified type\nthat can be cached.  The first parameter is a short string like \"http\"\nor \"ftp\".\n\ndrop\n$cache->drop(); # Drop ALL connections\n# which is just a synonym for:\n$cache->drop(sub{1}); # Drop ALL connections\n# drop all connections older than 22 seconds and add a reason for it!\n$cache->drop(22, \"Older than 22 secs dropped\");\n# which is just a synonym for:\n$cache->drop(sub {\nmy ($conn, $type, $key, $deposittime) = @;\nif ($deposittime < 22) {\n# true values drop the connection\nreturn 1;\n}\n# false values don't drop the connection\nreturn 0;\n}, \"Older than 22 secs dropped\" );\n\nDrop connections by some criteria.  The $checker argument is a\nsubroutine that is called for each connection.  If the routine returns\na TRUE value then the connection is dropped.  The routine is called\nwith \"($conn, $type, $key, $deposittime)\" as arguments.\n\nShortcuts: If the $checker argument is absent (or \"undef\") all cached\nconnections are dropped.  If the $checker is a number then all\nconnections untouched that the given number of seconds or more are\ndropped.  If $checker is a string then all connections of the given\ntype are dropped.\n\nThe \"reason\" is passed on to the \"dropped\" in LWP::ConnCache method.\n\nprune\n$cache->prune();\n\nCalling this method will drop all connections that are dead.  This is\ntested by calling the \"ping\" in LWP::ConnCache method on the\nconnections. If the \"ping\" in LWP::ConnCache method exists and returns\na false value, then the connection is dropped.\n\ngettypes\nmy @types = $cache->gettypes();\n\nThis returns all the \"type\" fields used for the currently cached\nconnections.\n\ngetconnections\nmy @conns = $cache->getconnections(); # all connections\nmy @conns = $cache->getconnections('http'); # connections for http\n\nThis returns all connection objects of the specified type.  If no type\nis specified then all connections are returned.  In scalar context the\nnumber of cached connections of the specified type is returned.\n",
                "subsections": []
            },
            "PROTOCOL METHODS": {
                "content": "The following methods are called by low-level protocol modules to try\nto save away connections and to get them back.\n\ndeposit\n$cache->deposit($type, $key, $conn);\n\nThis method adds a new connection to the cache.  As a result, other\nalready cached connections might be dropped.  Multiple connections with\nthe same type/key might be added.\n\nwithdraw\nmy $conn = $cache->withdraw($type, $key);\n\nThis method tries to fetch back a connection that was previously\ndeposited.  If no cached connection with the specified $type/$key is\nfound, then \"undef\" is returned.  There is not guarantee that a\ndeposited connection can be withdrawn, as the cache manger is free to\ndrop connections at any time.\n",
                "subsections": []
            },
            "INTERNAL METHODS": {
                "content": "The following methods are called internally.  Subclasses might want to\noverride them.\n\nenforcelimits\n$conn->enforcelimits([$type])\n\nThis method is called with after a new connection is added (deposited)\nin the cache or capacity limits are adjusted.  The default\nimplementation drops connections until the specified capacity limits\nare not exceeded.\n\ndropping\n$conn->dropping($connrecord, $reason)\n\nThis method is called when a connection is dropped.  The record\nbelonging to the dropped connection is passed as the first argument and\na string describing the reason for the drop is passed as the second\nargument.  The default implementation makes some noise if the\n$LWP::ConnCache::DEBUG variable is set and nothing more.\n",
                "subsections": []
            },
            "SUBCLASSING": {
                "content": "For specialized cache policy it makes sense to subclass\n\"LWP::ConnCache\" and perhaps override the \"deposit\" in LWP::ConnCache,\n\"enforcelimits\" in LWP::ConnCache, and \"dropping\" in LWP::ConnCache\nmethods.\n\nThe object itself is a hash.  Keys prefixed with \"cc\" are reserved for\nthe base class.\n",
                "subsections": []
            },
            "SEE ALSO": {
                "content": "LWP::UserAgent\n",
                "subsections": []
            },
            "COPYRIGHT": {
                "content": "Copyright 2001 Gisle Aas.\n\nThis library is free software; you can redistribute it and/or modify it\nunder the same terms as Perl itself.\n\nperl v5.34.0                      2026-05-22               LWP::ConnCache(3pm)",
                "subsections": []
            }
        }
    }
}