CacheStorageFactory
in package
Factory class for creating cache storage instances based on configuration
Table of Contents
Methods
- create() : ICacheStorage
- Create a cache storage instance based on configuration
- createAutoDetect() : ICacheStorage
- Detect and create the best available cache storage
- createFromConfig() : ICacheStorage
- Create storage from CacheConfig object
- getAvailableStorageTypes() : array<string|int, mixed>
- Get information about available storage types
- isAvailable() : bool
- Check if a specific storage type is available
- createFileStorage() : FileCacheStorage
- Create file-based cache storage
- createRedisStorage() : RedisCacheStorage
- Create Redis-based cache storage
Methods
create()
Create a cache storage instance based on configuration
public
static create(array<string|int, mixed> $Config) : ICacheStorage
Parameters
- $Config : array<string|int, mixed>
-
Cache configuration with keys:
- storage: Type of storage ('file' or 'redis')
- path: Path for file storage (required for 'file')
- redis: Redis configuration array (required for 'redis')
Tags
Return values
ICacheStoragecreateAutoDetect()
Detect and create the best available cache storage
public
static createAutoDetect([array<string|int, mixed> $Config = [] ]) : ICacheStorage
Parameters
- $Config : array<string|int, mixed> = []
-
Optional configuration to merge with defaults
Tags
Return values
ICacheStoragecreateFromConfig()
Create storage from CacheConfig object
public
static createFromConfig(CacheConfig $Config, string $BasePath) : ICacheStorage
Parameters
- $Config : CacheConfig
- $BasePath : string
-
Base path for file storage
Tags
Return values
ICacheStoragegetAvailableStorageTypes()
Get information about available storage types
public
static getAvailableStorageTypes() : array<string|int, mixed>
Return values
array<string|int, mixed>isAvailable()
Check if a specific storage type is available
public
static isAvailable(string $Type) : bool
Parameters
- $Type : string
-
Storage type ('file' or 'redis')
Return values
boolcreateFileStorage()
Create file-based cache storage
private
static createFileStorage(array<string|int, mixed> $Config) : FileCacheStorage
Parameters
- $Config : array<string|int, mixed>
Tags
Return values
FileCacheStoragecreateRedisStorage()
Create Redis-based cache storage
private
static createRedisStorage(array<string|int, mixed> $Config) : RedisCacheStorage
Parameters
- $Config : array<string|int, mixed>