Neuron-PHP

RedisCacheStorage
in package
implements ICacheStorage

Table of Contents

Interfaces

ICacheStorage

Properties

$_Config  : array<string|int, mixed>
$_Prefix  : string
$_Redis  : Redis|null

Methods

__construct()  : mixed
RedisCacheStorage constructor
__destruct()  : mixed
Destructor - ensure connection is closed
clear()  : bool
Clear all cache entries
delete()  : bool
Delete cache entry
disconnect()  : void
Disconnect from Redis
exists()  : bool
Check if cache key exists
gc()  : int
Run garbage collection to remove expired cache entries
isConnected()  : bool
Get Redis connection status
isExpired()  : bool
Check if cache entry is expired
read()  : string|null
Read content from cache
reconnect()  : bool
Reconnect to Redis if connection was lost
write()  : bool
Write content to cache
connect()  : void
Connect to Redis server

Properties

Methods

__construct()

RedisCacheStorage constructor

public __construct([array<string|int, mixed> $Config = [] ]) : mixed
Parameters
$Config : array<string|int, mixed> = []

Redis configuration with keys:

  • host: Redis server hostname (default: 127.0.0.1)
  • port: Redis server port (default: 6379)
  • database: Redis database index (default: 0)
  • prefix: Key prefix for cache entries (default: 'neuron_cache_')
  • timeout: Connection timeout in seconds (default: 2.0)
  • auth: Authentication password (optional)
  • persistent: Use persistent connections (default: false)
Tags
throws
CacheException

__destruct()

Destructor - ensure connection is closed

public __destruct() : mixed

delete()

Delete cache entry

public delete(string $Key) : bool
Parameters
$Key : string
Return values
bool

exists()

Check if cache key exists

public exists(string $Key) : bool
Parameters
$Key : string
Return values
bool

gc()

Run garbage collection to remove expired cache entries

public gc() : int
Return values
int

Number of entries removed

isConnected()

Get Redis connection status

public isConnected() : bool
Return values
bool

isExpired()

Check if cache entry is expired

public isExpired(string $Key) : bool
Parameters
$Key : string
Return values
bool

read()

Read content from cache

public read(string $Key) : string|null
Parameters
$Key : string
Return values
string|null

reconnect()

Reconnect to Redis if connection was lost

public reconnect() : bool
Return values
bool

write()

Write content to cache

public write(string $Key, string $Content, int $Ttl) : bool
Parameters
$Key : string
$Content : string
$Ttl : int
Tags
throws
CacheException
Return values
bool

        
On this page

Search results