CacheAdapterInterface
in
Interface for cache adapters in the Canvas LMS SDK.
All cache adapters must implement this interface to ensure consistent behavior across different cache backends.
Table of Contents
Methods
- clear() : void
- Clear all items from the cache.
- delete() : bool
- Delete an item from the cache.
- deleteByPattern() : int
- Delete items matching a pattern.
- get() : array<string, mixed>|null
- Retrieve an item from the cache.
- getStats() : array{hits: int, misses: int, size: int, entries: int}
- Get cache statistics.
- has() : bool
- Check if an item exists in the cache.
- set() : void
- Store an item in the cache.
Methods
clear()
Clear all items from the cache.
public
clear() : void
delete()
Delete an item from the cache.
public
delete(string $key) : bool
Parameters
- $key : string
-
The cache key
Return values
bool —True if deleted, false if not found
deleteByPattern()
Delete items matching a pattern.
public
deleteByPattern(string $pattern) : int
Parameters
- $pattern : string
-
The pattern to match (supports * wildcards)
Return values
int —The number of items deleted
get()
Retrieve an item from the cache.
public
get(string $key) : array<string, mixed>|null
Parameters
- $key : string
-
The cache key
Return values
array<string, mixed>|null —The cached data or null if not found/expired
getStats()
Get cache statistics.
public
getStats() : array{hits: int, misses: int, size: int, entries: int}
Return values
array{hits: int, misses: int, size: int, entries: int}has()
Check if an item exists in the cache.
public
has(string $key) : bool
Parameters
- $key : string
-
The cache key
Return values
bool —True if the item exists and is not expired
set()
Store an item in the cache.
public
set(string $key, array<string, mixed> $data[, int $ttl = 0 ]) : void
Parameters
- $key : string
-
The cache key
- $data : array<string, mixed>
-
The data to cache
- $ttl : int = 0
-
Time to live in seconds (0 = infinite)