{"id":15009542,"url":"https://github.com/festinuz/gecaso","last_synced_at":"2026-02-09T22:33:00.115Z","repository":{"id":57433364,"uuid":"97116725","full_name":"festinuz/gecaso","owner":"festinuz","description":"Generalized Caching Solution","archived":false,"fork":false,"pushed_at":"2017-07-26T14:04:40.000Z","size":40,"stargazers_count":2,"open_issues_count":2,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-11-07T15:12:50.478Z","etag":null,"topics":["cache","cache-storage","python-3-5","python-3-6","python3"],"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/festinuz.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-07-13T11:47:53.000Z","updated_at":"2017-07-20T17:19:06.000Z","dependencies_parsed_at":"2022-08-28T04:40:30.477Z","dependency_job_id":null,"html_url":"https://github.com/festinuz/gecaso","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"purl":"pkg:github/festinuz/gecaso","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/festinuz%2Fgecaso","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/festinuz%2Fgecaso/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/festinuz%2Fgecaso/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/festinuz%2Fgecaso/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/festinuz","download_url":"https://codeload.github.com/festinuz/gecaso/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/festinuz%2Fgecaso/sbom","scorecard":{"id":397825,"data":{"date":"2025-08-11","repo":{"name":"github.com/festinuz/gecaso","commit":"66ff0bbab6f5ab7dd2a3c5196698a0c0fb531e1d"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3,"checks":[{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Code-Review","score":0,"reason":"Found 0/9 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 30 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}}]},"last_synced_at":"2025-08-18T19:26:04.502Z","repository_id":57433364,"created_at":"2025-08-18T19:26:04.503Z","updated_at":"2025-08-18T19:26:04.503Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29283634,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-09T21:57:15.303Z","status":"ssl_error","status_checked_at":"2026-02-09T21:57:11.537Z","response_time":56,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: 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":["cache","cache-storage","python-3-5","python-3-6","python3"],"created_at":"2024-09-24T19:26:17.204Z","updated_at":"2026-02-09T22:33:00.089Z","avatar_url":"https://github.com/festinuz.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Gecaso\n\n[![PyPI version](https://badge.fury.io/py/gecaso.svg)](https://badge.fury.io/py/gecaso) [![master branch status](https://api.travis-ci.org/festinuz/gecaso.svg?branch=master)](https://travis-ci.org/festinuz/gecaso)\n\u003e Gecaso allows you to cache any function with ease.\n\n\n## Table of contents\n\n- [Features](#features)\n- [Examples](#examples)\n    + [Using default gecaso storages](#using-default-gecaso-storages)\n    + [Creating custom storage](#creating-custom-storage)\n- [Installation](#installation)\n- [Usage Guide](#usage-guide)\n    + [\"gecaso.cached\" function](#gecasocached-function)\n    + [\"gecaso.BaseStorage\" class](#gecasobasestorage-class)\n    + [Helper functions](#helper-functions)\n    + [Default storages](#default-storages)\n  * [Storage creation](#storage-creation)\n\n\n## Features\n\n* **Simple outside**: Requires little to no code to start caching. Plug in and enjoy.\n* **Complex inside**: Worry not about dog-pile effect or the varying key size.\n* **Asyncio-ready**: Works out of the box for both functions and coroutines. Any back-end can be used asynchronously.\n* **Flexible Caching**: Data can be cached per function to different back-ends and with different parameters.\n* **Extensible Back-end**: Create a custom storage for any backend with minimal effort.\n\n\n## Examples\n\n#### Using default gecaso storages\n```python\nimport gecaso\n\n\n@gecaso.cached(LRUStorage(maxsize=16), ttl=100)\ndef long_and_boring_function(time_to_sleep):\n    time.sleep(time_to_sleep)\n    return f'I have slept for {time_to_sleep} second(s)!'\n```\n\n#### Creating custom storage\nLets say you want to cache the result of some of your functions using Redis. All you need to do is write a simple class in which you specify the steps for setting and getting data from redis.\n\n1) Create a Redis storage:\n```python\nimport redis\nimport gecaso\n\n\nclass RedisStorage(gecaso.BaseStorage):\n    def __init__(self, redis_url):\n        self._storage = redis.from_url(redis_url)\n\n    async def get(self, key):\n        value, params = gecaso.unpack(self._storage[key])\n        return value\n\n    async def set(self, key, value, **params):\n        self._storage[key] = gecaso.pack(value, **params)\n\n    async def remove(self, *keys):\n        self._storage.remove(*keys)\n\nredis_storage = RedisStorage('valid_redis_url')\n```\n2) Set your cache for any function you want:\n\n```python\n@gecaso.cached(redis_storage, some_additional_cool_param='Hell yeah!')\ndef long_and_boring_function(time_to_sleep):\n    time.sleep(time_to_sleep)\n    return f'I have slept for {time_to_sleep} second(s)!'\n```\n\n## Installation\nInstall gecaso with pip:\n```\n    pip install gecaso\n```\nNote that at the time, gecaso only supports versions of python that are \u003e=3.5\n\n## Usage Guide\nGecaso was created to be a simple solution that can be easily extended to cover any needs of its users. Below is everything there is to know about using Gecaso.\n\n#### \"gecaso.cached\" function\nThis function is a wrapper that helps to set up cache for any synchronus or asynchronous function. It takes single positional argument, which must be an instance of class that is inherited from **BaseStorage**. It can also optionally be provided with a keyword argument **loop** which must be an instance of an event loop. Has two keyword arguments: **\\_loop** (event loop used by wrapper) and **\\_hash_key** (default is \"True\"; if true, key will have fixed size of 65 symbols). Any additional keyword arguments provided will be passed to every specified storage with every **set** call.\n\n#### \"gecaso.BaseStorage\" class\nAny storage provided to \"cached\" function should be inherited from this class. Base storage has 6 methods.\n\n* **get(self, key)**:  Abstract method that should be overridden. Must be asynchronous. MUST raise KeyError if key is not present in storage. If data was packed using **gecaso.pack** function before being stored, it must be unpacked using **gecaso.unpack** function.\n\n* **set(self, key, value, \\*\\*params)**: Abstract method that should be overridden. Must be asynchronous. It is recommended to pack provided value using **gecaso.pack** function before storing it in storage.\n\n* **remove(self, \\*keys)**: Abstract method that should be overridden. Must be asynchronous. Should delete every key that is passed in *keys* parameter and exists in storage.\n\n\n#### Helper functions\n* **gecaso.pack(value, \\*\\*params)**: Returns representation of object with fields named *data* and *params* as bytes object. Useful when creating a custom storage as it allows to store almost anything as 'bytes'.\n\n* **gecaso.unpack(value)**: Unpacks bytes object that was packed with **pack** method and returns *tuple(data, params)*.\n\n\n#### Default storages\n* **gecaso.MemoryStorage** storages all the data in RAM. Can be used as a default storage.\n* **gecaso.LRUStorage** is a simplified implementation that provides LRU cache functionality. Storage passed to its *\\_\\_init\\_\\_()* method will be used used to store values. This effectively allows to wrap any preexisting storage in *gecaso.LRUStorage* to get LRU cache functionality for that storage.\n\n### Storage creation\nThe process of using gecaso library usually includes creating a storage that fits your specific task the most. Here is a step by step example that should help you understand this process.\n\nLets say that we want to have a simple in-memory cache. Here are the steps we would take:\n\n1) Import gecaso and create the base of our class:\n```python\nimport gecaso\n\nclass LocalMemoryStorage(gecaso.BaseStorage):\n    def __init__(self):\n        self._storage = dict()  # Python's dict is a nice basic storage of data\n```\n\n2) Override async methods **set**, **get** and **remove** of gecaso.BaseStorage:\n```python\n    async def set(self, key, value):  # We don't want any additional parameters\n        params = dict()\n        self._storage[key] = gecaso.pack(value, **params)\n\n    async def get(self, key):\n        self.data = self._storage[key]  # If key is not present this will raise KeyError\n        value, params = gecaso.unpack(self._storage[key])\n        return value\n\n    async def remove(self, *keys):\n        for key in keys:\n            self._storage.pop(key, None)  # Not going to throw error if some of the keys do not exists\n```\n\nAnd now we're done!\nAfter the storage class has been created, all that is left to do is create an instance of this class and provide it to **cached** decorator whenever it is being called:\n\n```python\nlocal_storage = LocalMemoryStorage()\n\n@gecaso.cached(local_storage)\ndef foo(bar):\n    pass\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffestinuz%2Fgecaso","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffestinuz%2Fgecaso","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffestinuz%2Fgecaso/lists"}