PhoenixKit.Cache.Registry (phoenix_kit v1.6.15)
View SourceLightweight Registry wrapper for PhoenixKit.Cache instances.
This module provides simple process registration and discovery for cache processes.
Features
- Simple Registry wrapper using Elixir's Registry
- Process registration and discovery
- Basic cache listing and health checking
Usage
# Register a cache process (typically done automatically)
{:ok, pid} = PhoenixKit.Cache.start_link(name: :my_cache)
# List all registered caches
PhoenixKit.Cache.Registry.list_caches()
# Check if a cache is registered
PhoenixKit.Cache.Registry.cache_exists?(:my_cache)
# Get cache process PID
PhoenixKit.Cache.Registry.get_cache_pid(:my_cache)
Summary
Functions
Checks if a cache is registered and running.
Child specification for supervision trees.
Returns the count of registered cache processes.
Gets the PID of a registered cache process.
Performs a basic health check on registered caches.
Lists all registered cache instances with their basic status.
Looks up a cache process by name.
Starts the Registry for cache process registration.
Gets basic statistics for registered caches.
Creates a via tuple for process registration.
Functions
Checks if a cache is registered and running.
Examples
iex> PhoenixKit.Cache.Registry.cache_exists?(:my_cache)
true
@spec child_spec(any()) :: Supervisor.child_spec()
Child specification for supervision trees.
Examples
children = [
PhoenixKit.Cache.Registry
]
@spec count() :: non_neg_integer()
Returns the count of registered cache processes.
Examples
iex> PhoenixKit.Cache.Registry.count()
2
Gets the PID of a registered cache process.
Examples
iex> PhoenixKit.Cache.Registry.get_cache_pid(:my_cache)
#PID<0.123.0>
@spec health_check() :: map()
Performs a basic health check on registered caches.
Examples
PhoenixKit.Cache.Registry.health_check()
# => %{
# overall_status: :healthy,
# total_caches: 2,
# running_caches: 2,
# dead_caches: 0,
# registry_status: :running
# }
@spec list_caches() :: map()
Lists all registered cache instances with their basic status.
Examples
PhoenixKit.Cache.Registry.list_caches()
# => %{
# settings: %{pid: #PID<0.123.0>, status: :running},
# user_roles: %{pid: #PID<0.124.0>, status: :running}
# }
Looks up a cache process by name.
Examples
iex> PhoenixKit.Cache.Registry.lookup(:my_cache)
[{#PID<0.123.0>, nil}]
Starts the Registry for cache process registration.
Examples
{:ok, _pid} = PhoenixKit.Cache.Registry.start_link()
Gets basic statistics for registered caches.
Note: This provides basic registry-level stats. For detailed cache statistics, use PhoenixKit.Cache.stats/1 directly.
Examples
PhoenixKit.Cache.Registry.stats()
# => %{
# total_caches: 2,
# running_caches: 2,
# dead_caches: 0,
# cache_names: [:settings, :user_roles]
# }
PhoenixKit.Cache.Registry.stats(:my_cache)
# => %{registered: true, running: true, pid: #PID<0.123.0>}
Creates a via tuple for process registration.
Examples
iex> PhoenixKit.Cache.Registry.via_tuple(:my_cache)
{:via, Registry, {PhoenixKit.Cache.Registry, :my_cache}}