CacheApiInterface
in
Table of Contents
Methods
- cleanCache() : bool
- Clean out the cache.
- connect() : bool
- Connects to the cache method. This defines our $key. If this fails, we return false, otherwise we return true.
- getData() : mixed
- Retrieves an item from the cache.
- getImplementationClassKeyName() : string
- Gets the class identifier of the current caching API implementation.
- isSupported() : bool
- Checks whether we can use the cache method performed by this API.
- putData() : mixed
- Stores a value, regardless of whether or not the key already exists (in which case it will overwrite the existing value for that key).
Methods
cleanCache()
Clean out the cache.
public
cleanCache([string $type = '' ]) : bool
Parameters
- $type : string = ''
-
If supported, the type of cache to clear, blank/data or user.
Return values
bool —Whether or not we could clean the cache.
connect()
Connects to the cache method. This defines our $key. If this fails, we return false, otherwise we return true.
public
connect() : bool
Return values
bool —Whether or not the cache method was connected to.
getData()
Retrieves an item from the cache.
public
getData(string $key[, int|null $ttl = null ]) : mixed
Parameters
- $key : string
-
The key to use, the prefix is applied to the key name.
- $ttl : int|null = null
-
Overrides the default TTL. Not really used anymore, but is kept for backwards compatibility.
Tags
Return values
mixed —The result from the cache, if there is no data or it is invalid, we return null.
getImplementationClassKeyName()
Gets the class identifier of the current caching API implementation.
public
getImplementationClassKeyName() : string
Return values
string —the unique identifier for the current class implementation.
isSupported()
Checks whether we can use the cache method performed by this API.
public
isSupported([bool $test = false ]) : bool
Parameters
- $test : bool = false
-
Test if this is supported or enabled.
Return values
bool —Whether or not the cache is supported
putData()
Stores a value, regardless of whether or not the key already exists (in which case it will overwrite the existing value for that key).
public
putData(string $key, mixed $value[, int|null $ttl = null ]) : mixed
Parameters
- $key : string
-
The key to use, the prefix is applied to the key name.
- $value : mixed
-
The data we wish to save. Use null to delete.
- $ttl : int|null = null
-
How long (in seconds) the data should be cached for. The default TTL will be used if this is null.
Tags
Return values
mixed —Whether or not we could save this to the cache.