{"id":24054822,"url":"https://github.com/lingfromsh/psychic-spoon","last_synced_at":"2026-05-16T05:37:34.666Z","repository":{"id":191147333,"uuid":"458993231","full_name":"lingfromSh/psychic-spoon","owner":"lingfromSh","description":"A tool for managing chaos cache keys.","archived":false,"fork":false,"pushed_at":"2022-06-28T08:04:36.000Z","size":69,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-01-09T03:50:19.454Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Python","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/lingfromSh.png","metadata":{"files":{"readme":"README.md","changelog":null,"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}},"created_at":"2022-02-14T02:43:33.000Z","updated_at":"2022-06-16T16:24:26.000Z","dependencies_parsed_at":"2023-08-28T11:13:45.846Z","dependency_job_id":null,"html_url":"https://github.com/lingfromSh/psychic-spoon","commit_stats":null,"previous_names":["lingfromsh/psychic-spoon"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lingfromSh%2Fpsychic-spoon","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lingfromSh%2Fpsychic-spoon/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lingfromSh%2Fpsychic-spoon/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lingfromSh%2Fpsychic-spoon/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lingfromSh","download_url":"https://codeload.github.com/lingfromSh/psychic-spoon/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240840048,"owners_count":19866164,"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":[],"created_at":"2025-01-09T03:50:41.540Z","updated_at":"2026-05-16T05:37:29.636Z","avatar_url":"https://github.com/lingfromSh.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Psychic Spoon\n\n## Introduction\n\nCache key management always is a tough task during developing.\n\nCache a data may involve generating keys, converting data to right struct, assigning expiration, converting raw to\nproper python type and handling failures.\n\nThe purpose of `Psychic Spoon` is to keep your plenty of cache keys clear.\n\n## Concepts\n\nIn KV databases, a key is used as the unique identification to access the value. In practice, keys with the same pattern\nare generally designed as a kind of data with the same structure. And Various KV databases almost are same.\n\nTherefore, `Psychic Spoon` provides:\n\n1. a key object to describe key's pattern and data structure.\n2. a type object to describe data in python.\n3. a backend object to describe how data in python to store in database.\n\n### Key\n\n```python\nfrom psychic_spoon.key import Key\n```\n\n### Type\n\n- Boolean\n- Dict (support nested)\n- Float\n- Integer\n- List (support nested)\n- Set  (support nested)\n- String\n\n### Backend\n\n- RedisBackend\n    - RedisStringBackend\n    - RedisSetBackend\n\n## Usage\n\nFor example, we need a redis string to store a user's session dict.\n\n```python\nfrom datetime import timedelta\nfrom psychic_spoon.key import Key\nfrom psychic_spoon.types.dict import Dict\nfrom psychic_spoon.types.integer import Integer\nfrom psychic_spoon.types.set import Set\nfrom psychic_spoon.types.string import String\nfrom psychic_spoon.backends.redis_backend import RedisStringBackend\n\nbackend = RedisStringBackend(host=\"localhost\", port=6379)\n\nuser_session_cache = Key(\"user:{id}:session\",\n                         datatype=Dict(\n                             username=String,\n                             name=String,\n                             age=Integer,\n                             roles=Set(Integer),\n                             ip_address=Dict(\n                                 type=String,\n                                 address=String\n                             )\n                         ),\n                         backend=backend,\n                         ttl=timedelta(hours=12))\n\nkey = user_session_cache.build_key(id=1)\nuser_dict = {\n    \"username\": \"jame-curtis\",\n    \"name\": \"James Curtis\",\n    \"age\": 26,\n    \"roles\": {15, 82, 81},\n    \"ip_address\": {\n        \"type\": \"ipv4\",\n        \"address\": \"192.168.1.1\"\n    }\n}\n\n# Save your cache\nuser_session_cache.set(key, user_dict)\n\n# Fetch your cache\nuser_dict = user_session_cache.get(key)\n\n```\n\n## Roadmap\n\n- [ ] An event loop to handling success/failure callback\n- [ ] Replace pottery with RedisBackend\n- [ ] More support to redis model\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flingfromsh%2Fpsychic-spoon","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flingfromsh%2Fpsychic-spoon","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flingfromsh%2Fpsychic-spoon/lists"}