pyphi.cache.cache_utils.ByteBoundedStore#
- class pyphi.cache.cache_utils.ByteBoundedStore[source]#
Bases:
objectA dict that holds its byte weight steady once memory reaches the ceiling.
Insertion order is the recency order, so the least recently used entry is the first one iteration yields; a caller reinserts an entry on a hit to move it to the recent end. Until resident memory reaches the cache ceiling (see
memory_full()) the store grows freely. From then on it admits an entry by evicting least recently used ones, and refuses one too large to fit an empty store rather than flushing everything to hold it.Eviction holds occupancy steady; it does not reduce resident memory, since freeing a Python object returns its memory to the process allocator for reuse rather than to the operating system.
Not internally synchronized. A caller sharing a store across threads holds its own lock across
admit()anddiscard(); lock-free hits that pop and reinsert entries indatadirectly are tolerated, and the eviction loop never raises because of them.