{"id":20596946,"url":"https://github.com/petdance/template-plugin-cache","last_synced_at":"2026-04-22T13:31:23.300Z","repository":{"id":66709737,"uuid":"465478493","full_name":"petdance/template-plugin-cache","owner":"petdance","description":"Template::Plugin::Cache, a plugin for Perl's Template Toolkit that caches template output","archived":false,"fork":false,"pushed_at":"2022-03-10T03:27:15.000Z","size":16,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"dev","last_synced_at":"2025-03-06T15:18:27.332Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Perl","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/petdance.png","metadata":{"files":{"readme":"README.md","changelog":"Changes","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-03-02T21:43:11.000Z","updated_at":"2022-03-02T21:49:11.000Z","dependencies_parsed_at":null,"dependency_job_id":"0d04abf6-9c43-4a60-be23-620fd2554097","html_url":"https://github.com/petdance/template-plugin-cache","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/petdance/template-plugin-cache","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/petdance%2Ftemplate-plugin-cache","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/petdance%2Ftemplate-plugin-cache/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/petdance%2Ftemplate-plugin-cache/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/petdance%2Ftemplate-plugin-cache/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/petdance","download_url":"https://codeload.github.com/petdance/template-plugin-cache/tar.gz/refs/heads/dev","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/petdance%2Ftemplate-plugin-cache/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32139085,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-22T13:27:12.868Z","status":"ssl_error","status_checked_at":"2026-04-22T13:26:44.791Z","response_time":58,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-16T08:19:34.947Z","updated_at":"2026-04-22T13:31:23.275Z","avatar_url":"https://github.com/petdance.png","language":"Perl","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Template::Plugin::Cache\n\n## A plugin for Perl's Template Toolkit that caches template output\n\n## NAME\n\nTemplate::Plugin::Cache - cache output of templates\n\n## SYNOPSIS\n\n      [% USE cache = Cache %]\n\n      [% cache.inc(\n                   'template' =\u003e 'slow.html',\n                   'keys' =\u003e {'user.name' =\u003e user.name},\n                   'ttl' =\u003e 360\n                   ) %]\n\n      # or with a pre-defined Cache::* object and key\n\n      [% USE cache = Cache( cache =\u003e mycache ) %]\n\n      [% cache.inc(\n               'template' =\u003e 'slow.html',\n               'key'      =\u003e mykey,\n               'ttl'      =\u003e 360\n               )  %]\n\n## DESCRIPTION\n\nThe Cache plugin allows you to cache generated output from a template.\nYou load the plugin with the standard syntax:\n\n    [% USE cache = Cache %]\n\nThis creates a plugin object with the name 'cache'. You may also specify\nparameters for the default Cache module (Cache::FileCache), which is\nused for storage.\n\n    [% USE mycache = Cache(namespace =\u003e 'MyCache') %]\n\nOr use your own Cache object:\n\n    [% USE mycache = Cache(cache =\u003e mycacheobj) %]\n\nThe only methods currently available are include and process,\nabbreviated to \"inc\" and \"proc\" to avoid clashing with built-in\ndirectives. They work the same as the standard INCLUDE and PROCESS\ndirectives except that they will first look for cached output from the\ntemplate being requested and if they find it they will use that instead\nof actually running the template.\n\n    [% cache.inc(\n                'template' =\u003e 'slow.html',\n                'keys' =\u003e {'user.name' =\u003e user.name},\n                'ttl' =\u003e 360\n                ) %]\n\nThe template parameter names the file or block to include. The keys are\nvariables used to identify the correct cache file. Different values for\nthe specified keys will result in different cache files. The ttl\nparameter specifies the \"time to live\" for this cache file, in seconds.\n\nWhy the ugliness on the keys? Well, the TT dot notation can only be\nresolved correctly by the TT parser at compile time. It's easy to look\nup simple variable names in the stash, but compound names like\n\"user.name\" are hard to resolve at runtime. I may attempt to fake this\nin a future version, but it would be hacky and might cause problems.\n\nYou may also use your own key value:\n\n    [% cache.inc(\n                'template' =\u003e 'slow.html',\n                'key'      =\u003e yourkey,\n                'ttl'      =\u003e 360\n                ) %]\n\n## QUESTIONS\n\n* How is this different from the caching already built into Template Toolkit?\n\nThat cache is for caching the template files and the compiled version of\nthe templates. This cache is for caching the actual output from running\na template.\n\n* Who would benefit from this cache?\n\nThere are two situations where this might be useful. The first is if you\nare using a plugin or object inside your template that does something\nslow, like accessing a database or a disk drive or another process. The\nDBI plugin, for example. I don't build my apps this way (I use a\npipeline model with all the data collected before the template is run),\nbut I know some people do.\n\nThe other situation is if you have an unusually complex template that\ntakes a significant amount of time to run. Template Toolkit is quite\nfast, so it's uncommon for the actual template processing to take any\nnoticeable amount of time, but it is possible in extreme cases.\n\n*  Why don't you let users choose which Cache::Cache subclass they want to use?\n\nBecause Cache::FileCache is by far the fastest in nearly all cases.\n\n* Will you be offering support for other cache modules?\n\nI could, if there is a demand for it.\n\n* Any \"gotchas\" I should know about?\n\nIf you have a template that produces side effects when run, like\nmodifying a database or object, these side effects will not be captured\nand caching will break them. The cache only caches actual template\noutput.\n\nOf course, if you have a template which produces side effects, you are a\nvery naughty person and you get what you deserve.\n\n## AUTHORS\n\nAndy Lester (andy@petdance.com) is the current maintainer.\n\nPerrin Harkins (perrin@elem.com \u003cmailto:perrin@elem.com\u003e) wrote the\nfirst version of this plugin, with help and suggestions from various\nparties.\n\nPeter Karman \u003cpeter@peknet.com\u003e provided a patch to accept an existing\ncache object.\n\n## COPYRIGHT\n\nCopyright (C) 2022 Andy Lester\n\nCopyright (C) 2001 Perrin Harkins.\n\nThis module is free software; you can redistribute it and/or modify it\nunder the same terms as Perl itself.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpetdance%2Ftemplate-plugin-cache","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpetdance%2Ftemplate-plugin-cache","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpetdance%2Ftemplate-plugin-cache/lists"}