{"id":19611053,"url":"https://github.com/fenix-hub/gdcache","last_synced_at":"2026-05-18T03:31:30.691Z","repository":{"id":61499287,"uuid":"551937171","full_name":"fenix-hub/gdcache","owner":"fenix-hub","description":"Godot Engine plugin implementing different Cache Replacement Policies in GDScript. ","archived":false,"fork":false,"pushed_at":"2023-03-05T20:20:37.000Z","size":919,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-02-26T17:29:39.329Z","etag":null,"topics":["cache","database","gdscript","godot-engine","hacktoberfest","http","policies"],"latest_commit_sha":null,"homepage":"https://nicolosantilio.com/gdcache","language":"GDScript","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/fenix-hub.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,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-10-15T12:41:17.000Z","updated_at":"2024-01-19T16:08:05.000Z","dependencies_parsed_at":"2024-11-11T10:48:32.188Z","dependency_job_id":null,"html_url":"https://github.com/fenix-hub/gdcache","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/fenix-hub/gdcache","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fenix-hub%2Fgdcache","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fenix-hub%2Fgdcache/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fenix-hub%2Fgdcache/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fenix-hub%2Fgdcache/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fenix-hub","download_url":"https://codeload.github.com/fenix-hub/gdcache/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fenix-hub%2Fgdcache/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":275482760,"owners_count":25473109,"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","status":"online","status_checked_at":"2025-09-16T02:00:10.229Z","response_time":65,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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","database","gdscript","godot-engine","hacktoberfest","http","policies"],"created_at":"2024-11-11T10:35:41.298Z","updated_at":"2025-09-16T20:46:04.128Z","avatar_url":"https://github.com/fenix-hub.png","language":"GDScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# GDCache \n`GDCache` is a (POC™) GDScript Caching Algorithms and Replacement Policies addon for Godot Engine.\n\n`GDCache` exposes some ready-to-use Cache classes which can be used as singletons in any Godot Project to handle caching of any type of resource (local variable values, godot engine resources, http responses, database entities).\n\n## 💡 Rationale \nI started developing this library mainly because of educational reasons.  \nI wanted to study Caching technologies and replacement policies algorithms, and try to implement them in a very user-friendly language like GDScript.  \nThe result is a set of scripts which can be both used in production environments with Godot Engine or just for learning purpose.  \n\nThis library is not intended to replace or implement a workaround for how Godot Engine already handles [resource caching](https://docs.godotengine.org/en/stable/tutorials/scripting/resources.html), but instead this library provides a way to create caches and automatically apply preferred caching policies to projects which can find performance improvements through caching.\n\nFor example:\n- projects that rely on multiple http requests to fetch resources which are not cached from a server, or anyway to prevent making avoidable http requests through caching http responsess\n- projects that rely on multiple requests to SQL/noSQL databases and can prevent fetching multiple times the same resources thorugh caching database queries results\n\n`GDCache` also allows to create an in-memory cache, sort-of GDScript alternative to technologies like [Redis](https://redis.io/) or [Dragonflydb](https://dragonflydb.io/).\nEven though *currently* a GDScript standalone instance is far from being optimized just like a python/node webserver (since it is impossible to remove heavy modules/servers like the `physics` one), it offers the basics for furhter improvements and optimizations.\n\n## ✒️ Usage \n\n### 🛢️ Cache \nAll Cache types inherit from the `AbstractCache` class.  \nThis means that all Cache have some common functionalities, which can be overridden by all the other `\u003cany\u003eCache` implementations.  \nYou could even implement your own custom cache replacement policy!  \n  \nHere's an example using a First In / First Out cache with a capacity of 3\n```gdscript\nvar cache: FIFOCache = FIFOCache.new(3)\n\nfunc _ready() -\u003e void:\n    get_tree().get_root().add_child.call_deferred(cache) # not required\n    \n    cache.set_key.connect(_on_set) # will be called on `Get()`\n    cache.get_key.connect(_on_get) # will be called on `Set()`\n    \n    cache.Set(\"res1\", \"val1\")\n    cache.Set(\"res2\", \"val2\")\n    cache.Set(\"res3\", \"val3\")\n    \n    var r1 = cache.Get(\"res1\") # res1\n    var r2 = cache.Get(\"res3\") # res2\n    var r4 = cache.Get(\"res4\") # null\n    \n    cache.Set(\"res4\", \"val4\") # capacity is 3, so the FIFO policy will be used\n    \n    r1 = cache.Get(\"res1\") # null\n    r4 = cache.Get(\"res4\") # res4\n\n    print(cache)\n    # will print `{ \"res2\": \"val2\", \"res3\": \"val3\", \"res4\": \"val4\" }`\n```\n\nEven though `AbstractCache` inherits from `Node`, it is **not mandatory** to add a `Cache` node to the NodeTree, unless:\n(1) The `Cache` node uses time-based algorithms (such as `TLRUCache`) which require to instance some `Timer`s as sub-children\n(2) You want to make one or multiple caches as `Singleton`s in order to access them globally from your scripts\n\n\n### 🔎 Cache Monitors \nA `CacheMonitor` will let you \"monitor\" your cache properties and usage at runtime, without interferring with the cache itself.\n```gdscript\nvar rrcache: RRCache = RRCache.new(3)\nvar monitor: CacheMonitor = CacheMonitor.new(rrcache)\n\nfunc _ready() -\u003e void:\n    rrcache.Set(\"res1\", \"val1\")\n    rrcache.Get(\"res1\")\n\n    rrcache.Set(\"res2\", \"val2\")\n    rrcache.Get(\"res2\")\n\n    rrcache.Set(\"res3\", \"val3\")\n    rrcache.Get(\"res3\")\n\n    rrcache.Set(\"res4\", \"val4\") # will Evict a random key\n    rrcache.Get(\"res4\")\n    rrcache.Get(\"res1\")\n\n    print(monitor)\n```\n`print(monitor)` will print something like\n```\nCache: cache_1449834701\nPolicy: Random Replacement\nTotal Keys: 3/3\nSet Keys: 4\nGet Keys: 5 (166.67% ratio)\nHit Keys: 5 (100.00% ratio)\nMissed Keys: 0 (0.00% ratio)\nEvicted Keys: 1 (20.00% ratio)\n```\n\n## 📜 Supported Policies \n\nCurrently supported policies:\n\n- *Random Based*\n  - - [x] Random Replacement (`RRCache`)\n- *Queue Based*\n  - - [x] First in / First Out (`FIFOCache`)\n  - - [x] Last in / First Out (`LIFOCache`)\n- *Recency Based*\n  - - [x] Least Recently Used (`LRUCache`)\n  - - [x] Most Recently Used (`MRUCache`)\n  - - [x] Time aware Least Recently Used (`TLRUCache`)\n  - - [x] Segmented LRU (`SLRUCache`)\n  - *LRU Approximations*\n    - - [ ] Pseudo-LRU (`PLRUCache`)\n    - - [x] CLOCK (`CLOCKCache`)\n    - - [ ] CLOCK-Pro (`CLOCKProCache`)\n- *Simple frequency-based policies*\n  - - [ ] Least-frequently used (`LFUCache`)\n  - - [ ] Least frequent recently used (`LFRUCache`)\n  - - [ ] LFU with dynamic aging (`LFUDACache`)\n- *RRIP-style policies*\n  - - [ ] Re-Reference Interval Prediction (`RRIPCache`)\n  - - [ ] Static RRIP (`SRRIPCache`)\n  - - [ ] Bimodal RRIP (`BRRIPCache`)\n  - - [ ] Dynamic RRIP (`DRRIPCache`)\n- *Other cache replacement policies*\n  - - [ ] Low inter-reference recency set (`LIRSCache`)\n  - - [ ] Adaptive replacement cache (`ARCCache`)\n  - - [ ] AdaptiveClimb (`ACCache`)\n  - - [ ] Clock with adaptive replacement (`CARCache`)\n  - - [ ] Multi queue (`MQCache`)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffenix-hub%2Fgdcache","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffenix-hub%2Fgdcache","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffenix-hub%2Fgdcache/lists"}