{"id":21329959,"url":"https://github.com/bagher/fast-resource","last_synced_at":"2025-07-12T08:32:24.435Z","repository":{"id":65737593,"uuid":"588926020","full_name":"bagher/fast-resource","owner":"bagher","description":"fast-resource is a data transformation layer that sits between the database and the application's users, enabling quick data retrieval. It further enhances performance by caching data using Redis and Memcached.","archived":false,"fork":false,"pushed_at":"2023-05-15T16:11:40.000Z","size":19,"stargazers_count":10,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-06-11T07:54:53.450Z","etag":null,"topics":["cache","data-transformation","django","fastapi","flask","memcached","python","redis"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bagher.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":"2023-01-14T13:58:40.000Z","updated_at":"2024-12-09T10:02:45.000Z","dependencies_parsed_at":"2023-02-19T16:31:13.249Z","dependency_job_id":null,"html_url":"https://github.com/bagher/fast-resource","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/bagher/fast-resource","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bagher%2Ffast-resource","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bagher%2Ffast-resource/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bagher%2Ffast-resource/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bagher%2Ffast-resource/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bagher","download_url":"https://codeload.github.com/bagher/fast-resource/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bagher%2Ffast-resource/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264962441,"owners_count":23689812,"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":["cache","data-transformation","django","fastapi","flask","memcached","python","redis"],"created_at":"2024-11-21T22:13:24.106Z","updated_at":"2025-07-12T08:32:24.067Z","avatar_url":"https://github.com/bagher.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# fast-resource\n`fast-resource` is a data transformation layer that sits between the database and the application's users, enabling quick data retrieval. It further enhances performance by caching data using Redis and Memcached.\n## Why Use fast-resource?\nfast-resource is useful in situations where there are numerous data retrieval queries, multiple data sources requiring data aggregation, and shared data between entities that need to be cached. Additionally, the type of database used is not important.\n## Requirements\n- `redis`\n- `pymemcache`\n## Install\n```shell\n\u003e pip install fast-resource\n```\n## Usage\n\n### Quick Start\n\n```python\nfrom fast_resource import Resource\n\n\nclass UserResource(Resource):\n    class Meta:\n        fields = (\n            'id',\n            'name',\n        )\n\n    def name(self, input_data) -\u003e str:\n        return f'{input_data[\"name\"]} {input_data[\"family\"]}'\n\n\nUserResource({'id': 1, 'name': 'bagher', 'family': 'rokni'}).to_dict()\n```\n### Custom output\n```python\nUserResource({'id': 1, 'name': 'bagher', 'family': 'rokni'}).to_dict(('id',))\n```\n### Use cache decoder\n```python\nfrom redis.client import Redis\nfrom fast_resource import Resource, cache\nfrom fast_resource.cache import RedisCache\n\ndef my_key_builder(input_data, field):\n    return f'user.{input_data[\"id\"]}.{field}'\n\nclass UserResource(Resource):\n    class Meta:\n        fields = (\n            'id',\n            'name',\n        )\n\n    @cache(key=my_key_builder)\n    def name(self, input_data) -\u003e str:\n        return f'{input_data[\"name\"]} {input_data[\"family\"]}'\n\n\nResource.cache_init(driver=RedisCache(Redis()))\nUserResource({'id': 1, 'name': 'bagher', 'family': 'rokni'}).to_dict()\n```\n### Custom cache expire_time\n```python\n@cache(key=my_key_builder, expire_time=60)\ndef name(self, input_data) -\u003e str:\n    return f'{input_data[\"name\"]} {input_data[\"family\"]}'\n```\n### Cache delete\n```python\nUserResource({'id': 1, 'name': 'bagher', 'family': 'rokni'}).cache_delete()\n```\n### Cache delete \u0026 rebuild\n```python\nUserResource({'id': 1, 'name': 'bagher', 'family': 'rokni'}).cache_delete(rebuild=True)\n```\n\n### Cache delete by keys\n```python\nUserResource.cache_delete_by_keys(['user.1.name'])\n```\n\n### Create collection\n```python\nuser_collection = UserResource.collection([\n    {'id': 1, 'name': 'bagher', 'family': 'rokni'},\n    {'id': 2, 'name': 'sepehr', 'family': 'rokni'},\n    {'id': 3, 'name': 'sama', 'family': 'rokni'},\n])\nuser_collection.to_dict()\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbagher%2Ffast-resource","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbagher%2Ffast-resource","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbagher%2Ffast-resource/lists"}