\Omega\Cache\Adapter AbstractCacheAdapter

Abstract cache adapter class.

The AbstractCacheAdapter class provides a foundation for implementing cache adapters. It implements the methods defined in the CacheAdapterInterface and adds some common properties and behaviors.

Summary

Methods
Properties
Constants
__construct
has
get
put
forget
flush
config
cached
config
No public constants found
No protected methods found
No protected properties found
No protected constants found
No private methods found
No private properties found
No private constants found

Properties

$cached

$cached : array

Cacheds data.

Type

array<string, mixed> — Holds an array to store cached data.

$config

$config : array

Type

array<string|int, mixed>

Methods

__construct()

__construct(array  $config) : void

AbstractCacheAdapter class constructor.

Parameters

array $config

Holds the configuration options for the cache adapter.

Returns

void —

has()

has(string  $key) : bool

Check if a value exists in the cache.

Parameters

string $key

Holds the cache key to check.

Returns

bool —

Returns true if the key exists in the cache, otherwise false.

get()

get(string  $key, mixed  $default = null) : mixed

Retrieve a cached value by its key.

Parameters

string $key

Holds the cache key to retrieve.

mixed $default

Holds the default value to return if the key is not found.

Returns

mixed —

Return the cached value if found, otherwise the default value.

put()

put(string  $key, mixed  $value, ?int  $seconds = null) : $this

Store a value in the cache with an optional expiration time.

Parameters

string $key

Holds the cache key to store.

mixed $value

Holds the value to store in the cache.

?int $seconds

Holds the number of seconds until the cache item expires (null for no expiration).

Returns

$this —

Return the cache adapter instance.

forget()

forget(string  $key) : $this

Remove a single cache value by its key.

Parameters

string $key

Holds the cache key to remove.

Returns

$this —

Return the cache adapter instance.

flush()

flush() : $this

Remove all cached values.

Returns

$this —

Return the cache adapter instance.

config()

config() : array<string,mixed>

Get the config.

Returns

array

Return an array of config.