Raxol.Terminal.Cache.System (Raxol v0.5.0)

View Source

Unified caching system for the Raxol terminal emulator. This module provides a centralized caching mechanism that consolidates all caching operations across the terminal system, including:

  • Buffer caching
  • Animation caching
  • Scroll caching
  • Clipboard caching
  • General purpose caching

Summary

Functions

Returns a specification to start this module under a supervisor.

Clears the cache.

Gets a value from the cache.

Invalidates a cache entry.

Returns the current monotonic time in milliseconds. This is used for cache expiration and timing operations.

Puts a value in the cache.

Starts the unified cache system.

Gets cache statistics.

Types

cache_entry()

@type cache_entry() :: %{
  value: cache_value(),
  size: non_neg_integer(),
  created_at: integer(),
  last_access: integer(),
  access_count: non_neg_integer(),
  ttl: integer() | nil,
  metadata: map()
}

cache_key()

@type cache_key() :: term()

cache_stats()

@type cache_stats() :: %{
  size: non_neg_integer(),
  max_size: non_neg_integer(),
  hit_count: non_neg_integer(),
  miss_count: non_neg_integer(),
  hit_ratio: float(),
  eviction_count: non_neg_integer()
}

cache_value()

@type cache_value() :: term()

namespace()

@type namespace() :: :buffer | :animation | :scroll | :clipboard | :general

Functions

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

clear(opts \\ [])

Clears the cache.

Parameters

  • opts - Clear options
    • :namespace - Cache namespace (default: :general)

get(key, opts \\ [])

Gets a value from the cache.

Parameters

  • key - The cache key
  • opts - Get options
    • :namespace - Cache namespace (default: :general)

invalidate(key, opts \\ [])

Invalidates a cache entry.

Parameters

  • key - The cache key
  • opts - Invalidate options
    • :namespace - Cache namespace (default: :general)

monotonic_time()

@spec monotonic_time() :: integer()

Returns the current monotonic time in milliseconds. This is used for cache expiration and timing operations.

put(key, value, opts \\ [])

Puts a value in the cache.

Parameters

  • key - The cache key
  • value - The value to cache
  • opts - Put options
    • :namespace - Cache namespace (default: :general)
    • :ttl - Time-to-live in seconds
    • :metadata - Additional metadata

start_link(opts \\ [])

Starts the unified cache system.

Options

  • :max_size - Maximum cache size in bytes (default: 100MB)
  • :default_ttl - Default time-to-live in seconds (default: 3600)
  • :eviction_policy - Cache eviction policy (:lru, :lfu, :fifo) (default: :lru)
  • :compression_enabled - Whether to enable compression (default: true)
  • :namespace_configs - Configuration for specific namespaces

stats(opts \\ [])

Gets cache statistics.

Parameters

  • opts - Stats options
    • :namespace - Cache namespace (default: :general)