{"id":15019260,"url":"https://github.com/nigelhorne/class-simple-readonly-cached","last_synced_at":"2025-10-04T13:46:09.751Z","repository":{"id":56839076,"uuid":"210064436","full_name":"nigelhorne/Class-Simple-Readonly-Cached","owner":"nigelhorne","description":"Cache messages to an object","archived":false,"fork":false,"pushed_at":"2025-04-03T20:18:23.000Z","size":97,"stargazers_count":0,"open_issues_count":1,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-03T21:24:13.846Z","etag":null,"topics":["cpan","optimization","perl","perl-module","perl5"],"latest_commit_sha":null,"homepage":"","language":"Perl","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nigelhorne.png","metadata":{"files":{"readme":"README.md","changelog":"Changes","contributing":null,"funding":null,"license":"LICENSE","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":"2019-09-21T23:15:19.000Z","updated_at":"2025-04-03T20:18:27.000Z","dependencies_parsed_at":"2022-08-28T23:30:26.802Z","dependency_job_id":"f0c1a2a0-6773-47dc-9744-08f9bbdb2600","html_url":"https://github.com/nigelhorne/Class-Simple-Readonly-Cached","commit_stats":{"total_commits":59,"total_committers":4,"mean_commits":14.75,"dds":"0.23728813559322037","last_synced_commit":"98494b1335a4b83759a77d40b39ba64e0018d717"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nigelhorne%2FClass-Simple-Readonly-Cached","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nigelhorne%2FClass-Simple-Readonly-Cached/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nigelhorne%2FClass-Simple-Readonly-Cached/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nigelhorne%2FClass-Simple-Readonly-Cached/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nigelhorne","download_url":"https://codeload.github.com/nigelhorne/Class-Simple-Readonly-Cached/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248103806,"owners_count":21048238,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["cpan","optimization","perl","perl-module","perl5"],"created_at":"2024-09-24T19:53:14.227Z","updated_at":"2025-10-04T13:46:09.743Z","avatar_url":"https://github.com/nigelhorne.png","language":"Perl","funding_links":[],"categories":[],"sub_categories":[],"readme":"# NAME\n\nClass::Simple::Readonly::Cached - cache messages to an object\n\n# VERSION\n\nVersion 0.12\n\n# SYNOPSIS\n\nA sub-class of [Class::Simple](https://metacpan.org/pod/Class%3A%3ASimple) which caches calls to read\nthe status of an object that are otherwise expensive.\n\nIt is up to the caller to maintain the cache if the object comes out of sync with the cache,\nfor example by changing its state.\n\nYou can use this class to create a caching layer to an object of any class\nthat works on objects which doesn't change its state based on input:\n\n    use Class::Simple::Readonly::Cached;\n\n    my $obj = Class::Simple-\u003enew();\n    $obj-\u003eval('foo');\n    $obj = Class::Simple::Readonly::Cached-\u003enew(object =\u003e $obj, cache =\u003e {});\n    my $val = $obj-\u003eval();\n    print \"$val\\n\";     # Prints \"foo\"\n\n    #... set $obj to be some other class which will take an argument 'a',\n    #   with a value 'b'\n\n    $val = $obj-\u003eval(a =\u003e 'b');\n\nNote that when the object goes out of scope or becomes undefined (i.e. DESTROYed),\nthe cache is cleared.\n\n# SUBROUTINES/METHODS\n\n## new\n\nCreates a Class::Simple::Readonly::Cached object.\n\nIt takes one mandatory parameter: cache,\nwhich is either an object which understands purge(), get() and set() calls,\nsuch as an [CHI](https://metacpan.org/pod/CHI) object;\nor is a reference to a hash where the return values are to be stored.\n\nIt takes one optional argument: object,\nwhich is an object which is taken to be the object to be cached.\nIf not given, an object of the class [Class::Simple](https://metacpan.org/pod/Class%3A%3ASimple) is instantiated\nand that is used.\n\n    use Gedcom;\n\n    my %hash;\n    my $person = Gedcom::Person-\u003enew();\n    # ...Set up some data\n    my $object = Class::Simple::Readonly::Cached(object =\u003e $person, cache =\u003e \\%hash);\n    my $father1 = $object-\u003efather();    # Will call gedcom-\u003efather() to get the person's father\n    my $father2 = $object-\u003efather();    # Will retrieve the father from the cache without calling person-\u003efather()\n\nTakes one optional argument: quiet,\nif you attempt to cache an object that is already cached, rather than create\nanother copy you receive a warning and the previous cached copy is returned.\nThe 'quiet' option, when non-zero, silences the warning.\n\n## object\n\nReturn the encapsulated object\n\n## state\n\nReturns the state of the object\n\n    print Data::Dumper-\u003enew([$obj-\u003estate()])-\u003eDump();\n\n## can\n\nReturns if the embedded object can handle a message\n\n## isa\n\nReturns if the embedded object is the given type of object\n\n# AUTHOR\n\nNigel Horne, `\u003cnjh at bandsman.co.uk\u003e`\n\n# BUGS\n\nDoesn't work with [Memoize](https://metacpan.org/pod/Memoize).\n\nPlease report any bugs or feature requests to [https://github.com/nigelhorne/Class-Simple-Readonly-Cached/issues](https://github.com/nigelhorne/Class-Simple-Readonly-Cached/issues).\nI will be notified, and then you'll\nautomatically be notified of progress on your bug as I make changes.\n\n# SEE ALSO\n\n- [constant::defer](https://metacpan.org/pod/constant%3A%3Adefer)\n- [Class::Simple](https://metacpan.org/pod/Class%3A%3ASimple)\n- [CHI](https://metacpan.org/pod/CHI)\n- [Data::Reuse](https://metacpan.org/pod/Data%3A%3AReuse)\n\n    Values are shared between `Class::Simple::Readonly::Cached` objects, since they are read-only.\n\n# SUPPORT\n\nThis module is provided as-is without any warranty.\n\nYou can find documentation for this module with the perldoc command.\n\n    perldoc Class::Simple::Readonly::Cached\n\nYou can also look for information at:\n\n- MetaCPAN\n\n    [https://metacpan.org/release/Class-Simple-Readonly-Cached](https://metacpan.org/release/Class-Simple-Readonly-Cached)\n\n- Source Repository\n\n    [https://github.com/nigelhorne/Class-Simple-Readonly-Cached](https://github.com/nigelhorne/Class-Simple-Readonly-Cached)\n\n- CPANTS\n\n    [http://cpants.cpanauthors.org/dist/Class-Simple-Readonly-Cached](http://cpants.cpanauthors.org/dist/Class-Simple-Readonly-Cached)\n\n- CPAN Testers' Matrix\n\n    [http://matrix.cpantesters.org/?dist=Class-Simple-Readonly-Cached](http://matrix.cpantesters.org/?dist=Class-Simple-Readonly-Cached)\n\n- CPAN Testers Dependencies\n\n    [http://deps.cpantesters.org/?module=Class::Simple::Readonly::Cached](http://deps.cpantesters.org/?module=Class::Simple::Readonly::Cached)\n\n- Search CPAN\n\n    [http://search.cpan.org/dist/Class-Simple-Readonly-Cached/](http://search.cpan.org/dist/Class-Simple-Readonly-Cached/)\n\n# LICENSE AND COPYRIGHT\n\nAuthor Nigel Horne: `njh@bandsman.co.uk`\nCopyright (C) 2019-2025 Nigel Horne\n\nUsage is subject to licence terms.\nThe licence terms of this software are as follows:\nPersonal single user, single computer use: GPL2\nAll other users (including Commercial, Charity, Educational, Government)\nmust apply in writing for a licence for use from Nigel Horne at the\nabove e-mail.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnigelhorne%2Fclass-simple-readonly-cached","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnigelhorne%2Fclass-simple-readonly-cached","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnigelhorne%2Fclass-simple-readonly-cached/lists"}