Raxol.Terminal.Buffer.CacheManager (Raxol v0.5.0)
View SourceManages caching for the terminal buffer system. Provides efficient caching mechanisms for frequently accessed buffer regions.
Summary
Functions
Gets a value from the cache.
Invalidates a cache entry.
Creates a new cache manager with the specified maximum size.
Puts a value in the cache.
Gets cache statistics.
Types
@type cache_entry() :: %{ data: term(), last_access: integer(), access_count: non_neg_integer() }
@type cache_key() :: {non_neg_integer(), non_neg_integer(), non_neg_integer(), non_neg_integer()}
@type t() :: %Raxol.Terminal.Buffer.CacheManager{ cache: %{required(cache_key()) => cache_entry()}, current_size: non_neg_integer(), hit_count: non_neg_integer(), max_size: non_neg_integer(), miss_count: non_neg_integer() }
Functions
Gets a value from the cache.
Parameters
cache
- The cache manager instancekey
- The cache key
Returns
{:ok, value}
- The cached value if found:miss
- If the value is not in cache
Invalidates a cache entry.
Parameters
cache
- The cache manager instancekey
- The cache key to invalidate
Returns
- Updated cache manager instance
Creates a new cache manager with the specified maximum size.
Parameters
max_size
- Maximum number of cache entries (default: 1000)
Returns
- A new cache manager instance
Puts a value in the cache.
Parameters
cache
- The cache manager instancekey
- The cache keyvalue
- The value to cache
Returns
- Updated cache manager instance
Gets cache statistics.
Parameters
cache
- The cache manager instance
Returns
- Map containing cache statistics