{"id":23131663,"url":"https://github.com/peopledoc/python-pussycache","last_synced_at":"2025-04-04T07:28:25.454Z","repository":{"id":13710610,"uuid":"16404577","full_name":"peopledoc/python-pussycache","owner":"peopledoc","description":"Cache Backend system for python objects","archived":false,"fork":false,"pushed_at":"2014-02-07T10:41:16.000Z","size":523,"stargazers_count":3,"open_issues_count":1,"forks_count":0,"subscribers_count":16,"default_branch":"master","last_synced_at":"2025-03-22T20:38:38.389Z","etag":null,"topics":["approved-public","ghec-mig-migrated"],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/peopledoc.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-01-31T09:55:56.000Z","updated_at":"2023-09-27T19:09:33.000Z","dependencies_parsed_at":"2022-09-06T00:20:48.371Z","dependency_job_id":null,"html_url":"https://github.com/peopledoc/python-pussycache","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/peopledoc%2Fpython-pussycache","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/peopledoc%2Fpython-pussycache/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/peopledoc%2Fpython-pussycache/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/peopledoc%2Fpython-pussycache/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/peopledoc","download_url":"https://codeload.github.com/peopledoc/python-pussycache/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247137875,"owners_count":20889945,"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":["approved-public","ghec-mig-migrated"],"created_at":"2024-12-17T11:15:49.004Z","updated_at":"2025-04-04T07:28:25.435Z","avatar_url":"https://github.com/peopledoc.png","language":"Python","readme":"Python pussy cache\n==================\n\nPython pussy cache is a Cache system for python objects.\n\nCache backends can be in-memory or redis/ You can even use the django\ncache framework with Python-pussy-cache.\n\nGiven a one of the cache backends and any Python class you have\ndefine, Python-pussy-cache will cache the results of methods you have\ndefine and will also manage the cache invalidation by timestamp or\nwith methods you have defined.\n\n[![Build Status](https://secure.travis-ci.org/novapost/python-pussycache.png?branch=master)](https://travis-ci.org/novapost/python-pussycache)\n[![python-pussycache](https://pypip.in/v/pussycache/badge.png)](https://crate.io/packages/pussycache/)\n[![python-pussycache](https://pypip.in/d/pussycache/badge.png)](https://crate.io/packages/pussycache/)\n\n\nHere is an example to make the thing clearer\n\n```python\nimport time\nfrom pussycache.proxy import BaseProxy\nfrom pussycache.cache import BaseCacheBackend\n# Here is a simple class where some methods need to be cached\n\nclass MyClass(object):\n\n      def a_long_task(self, delta):\n          time.sleep(delta)\n          return delta\n\n      def forget_about_time(self):\n          return None\n\n# We set an in memory cache backend with a TTL of 30 seconds.\n\ncache = BaseCacheBackend(30)\n\ncache_proxy = BaseProxy(MyClass(), cache=cache,\n             cached_methods=[\"a_long_task\"],\n             invalidate_methods={\"forget_about_time\": [\"a_long_task\"]})\n\ncachedinstance = cache_proxy\n# your cachedinstance is now\n# ready to use. It will just work like a regular MyClass object\n\nprint cachedinstance.a_long_task(10)\n# 10 seconds later\n10\n# if we call the same method a second time:\nprint cachedinstance.a_long_task(10)\n10\n# result is returned immediatly because it's in the cache\n# but\nprint cachedinstance.a_long_task(3)\n3\n# with different parameters, the result is not cached yet.\n# if you want to invalidate the cache for this method:\nprint cachedinstance.forget_about_time()\nprint cachedinstance.a_long_task(10)\n# 10 seconds later\n10\n```\n\nOf course, If you need direct access to the cache backend, you can\ncall it directly. Let's say you need to invalidate ALL the cache :\n\n```python\n\ncachedinstance._cache.clear()\n```\n\nThe same apply if you need to call directly the cache:\n\n```python\ncachedinstance.\\_cache.set(\"mykey\", \"my value\", 10)\ncachedinstance.\\_cache.get(\"mykey\")\n\"my value\"\n#and 10 seconds later:\ncachedinstance.\\_cache.get(\"mykey\")\n#the value is gone from the cache\n```\n\n\nTests\n-----\n\nTo run test, just install tox with ``pip install tox`` and run\n\n    tox\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpeopledoc%2Fpython-pussycache","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpeopledoc%2Fpython-pussycache","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpeopledoc%2Fpython-pussycache/lists"}