\Omega\Cache\Adapter CacheAdapterInterface

Cache adapter interface.

The CacheAdapterInterface defines the contract for cache adapters, allowing different cache storage systems to be used interchangeably within the framework.

Summary

Methods
Constants
has()
get()
put()
forget()
flush()
No public constants found

Methods

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|null  $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|null $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.