#cache Clear
Tags #php #kotlin #bash #go #sql #rust #typescript #html #java #python #files #utils #strings #http #concurrency #async #json #arrays #security #types #crypto #database #dates #format
PHP Memoize a Function's Result
Cache the result of an expensive pure function by its arguments. Returns a closure with the same call signature that only invokes the inner function once per unique argument set.
JavaScript WeakRef Object Cache
A cache backed by WeakRef and FinalizationRegistry. Stored values are held weakly — the garbage collector can reclaim them if memory pressure is high, and the registry automatically cleans up stale entries from the internal map. Ideal for caching large objects (DOM nodes, rendered images) without causing memory leaks.
JavaScript LocalStorage with Expiry
Extends localStorage with TTL (time-to-live) support. setItem stores a value alongside an expiry timestamp. getItem returns null and removes the key if the TTL has elapsed. Useful for caching API responses client-side, storing ephemeral UI state, and implementing remember-me tokens without a backend session.
Python functools.cache Memoization
Wrap any pure function with @cache (Python 3.9+) and get an unbounded memoization layer for free. Use @lru_cache(maxsize=N) when you need a bounded cache.
PHP Simple File-Backed Cache
A tiny key-value cache with TTL, persisted as a serialized PHP file per key. Good enough for memoizing expensive computations on a single machine; replace with Redis when scaling out.