|
| __construct (BagOStuff $inner, string $prefix, string $secret) |
|
| get ( $key, $default=null) |
| Fetches a value from the cache. More...
|
|
| set ( $key, $value, $ttl=null) |
| Persists data in the cache, uniquely referenced by a key with an optional expiration TTL time. More...
|
|
| delete ( $key) |
| Delete an item from the cache by its unique key. More...
|
|
| clear () |
| Wipes clean the entire cache's keys. More...
|
|
| getMultiple ( $keys, $default=null) |
| Obtains multiple cache items by their unique keys. More...
|
|
| setMultiple ( $values, $ttl=null) |
| Persists a set of key => value pairs in the cache, with an optional TTL. More...
|
|
| deleteMultiple ( $keys) |
| Deletes multiple cache items in a single operation. More...
|
|
| has ( $key) |
| Determines whether an item is present in the cache. More...
|
|
- Copyright
- GPL-2.0-or-later
◆ __construct()
Wikibase\Lib\SimpleCacheWithBagOStuff::__construct |
( |
BagOStuff |
$inner, |
|
|
string |
$prefix, |
|
|
string |
$secret |
|
) |
| |
- Parameters
-
BagOStuff | $inner | |
string | $prefix | While setting and getting all keys will be prefixed with this string |
string | $secret | Will be used to create a signature for stored values |
- Exceptions
-
◆ assertKeyIsValid()
Wikibase\Lib\SimpleCacheWithBagOStuff::assertKeyIsValid |
( |
|
$key | ) |
|
|
private |
◆ assertKeysAreValid()
Wikibase\Lib\SimpleCacheWithBagOStuff::assertKeysAreValid |
( |
|
$keys | ) |
|
|
private |
◆ assertKeysAreValidAllowIntegers()
Wikibase\Lib\SimpleCacheWithBagOStuff::assertKeysAreValidAllowIntegers |
( |
|
$keys | ) |
|
|
private |
◆ clear()
Wikibase\Lib\SimpleCacheWithBagOStuff::clear |
( |
| ) |
|
Wipes clean the entire cache's keys.
- Returns
- bool True on success and false on failure.
◆ delete()
Wikibase\Lib\SimpleCacheWithBagOStuff::delete |
( |
|
$key | ) |
|
Delete an item from the cache by its unique key.
- Parameters
-
string | $key | The unique cache key of the item to delete. |
- Returns
- bool True if the item was successfully removed. False if there was an error.
- Exceptions
-
◆ deleteMultiple()
Wikibase\Lib\SimpleCacheWithBagOStuff::deleteMultiple |
( |
|
$keys | ) |
|
Deletes multiple cache items in a single operation.
- Parameters
-
iterable | $keys | A list of string-based keys to be deleted. |
- Returns
- bool True if the items were successfully removed. False if there was an error.
- Exceptions
-
◆ get()
Wikibase\Lib\SimpleCacheWithBagOStuff::get |
( |
|
$key, |
|
|
|
$default = null |
|
) |
| |
Fetches a value from the cache.
- Parameters
-
string | $key | The unique key of this item in the cache. |
mixed | $default | Default value to return if the key does not exist. |
- Returns
- mixed The value of the item from the cache, or $default in case of cache miss.
- Exceptions
-
◆ getMultiple()
Wikibase\Lib\SimpleCacheWithBagOStuff::getMultiple |
( |
|
$keys, |
|
|
|
$default = null |
|
) |
| |
Obtains multiple cache items by their unique keys.
- Parameters
-
iterable | $keys | A list of keys that can obtained in a single operation. |
mixed | $default | Default value to return for keys that do not exist. |
- Returns
- iterable A list of key => value pairs. Cache keys that do not exist or are stale will have $default as value.
- Exceptions
-
◆ has()
Wikibase\Lib\SimpleCacheWithBagOStuff::has |
( |
|
$key | ) |
|
Determines whether an item is present in the cache.
NOTE: It is recommended that has() is only to be used for cache warming type purposes and not to be used within your live applications operations for get/set, as this method is subject to a race condition where your has() will return true and immediately after, another script can remove it making the state of your app out of date.
- Parameters
-
string | $key | The cache item key. |
- Returns
- bool
- Exceptions
-
◆ isIterable()
Wikibase\Lib\SimpleCacheWithBagOStuff::isIterable |
( |
|
$var | ) |
|
|
private |
◆ normalizeTtl()
Wikibase\Lib\SimpleCacheWithBagOStuff::normalizeTtl |
( |
|
$ttl | ) |
|
|
private |
- Parameters
-
null | int | DateInterval | $ttl | The TTL value of this item. If no value is sent and the driver supports TTL then the library may set a default value for it or let the driver take care of that. |
- Returns
- int Time to live in form of seconds from now
- Exceptions
-
◆ serialize()
Wikibase\Lib\SimpleCacheWithBagOStuff::serialize |
( |
|
$value | ) |
|
|
private |
◆ set()
Wikibase\Lib\SimpleCacheWithBagOStuff::set |
( |
|
$key, |
|
|
|
$value, |
|
|
|
$ttl = null |
|
) |
| |
Persists data in the cache, uniquely referenced by a key with an optional expiration TTL time.
- Parameters
-
string | $key | The key of the item to store. |
mixed | $value | The value of the item to store, must be serializable. |
null | int | DateInterval | $ttl | Optional. The TTL value of this item. If no value is sent and the driver supports TTL then the library may set a default value for it or let the driver take care of that. |
- Returns
- bool True on success and false on failure.
- Exceptions
-
◆ setMultiple()
Wikibase\Lib\SimpleCacheWithBagOStuff::setMultiple |
( |
|
$values, |
|
|
|
$ttl = null |
|
) |
| |
Persists a set of key => value pairs in the cache, with an optional TTL.
- Parameters
-
iterable | $values | A list of key => value pairs for a multiple-set operation. |
null | int | DateInterval | $ttl | Optional. The TTL value of this item. If no value is sent and the driver supports TTL then the library may set a default value for it or let the driver take care of that. |
- Returns
- bool True on success and false on failure.
- Exceptions
-
◆ toArray()
Wikibase\Lib\SimpleCacheWithBagOStuff::toArray |
( |
|
$var | ) |
|
|
private |
- Parameters
-
mixed | $var | the object to turn to array |
- Returns
- array
- Exceptions
-
◆ toAssociativeArray()
Wikibase\Lib\SimpleCacheWithBagOStuff::toAssociativeArray |
( |
|
$var | ) |
|
|
private |
- Parameters
-
mixed | $var | the object to turn to associative array |
- Returns
- array
- Exceptions
-
◆ unserialize()
Wikibase\Lib\SimpleCacheWithBagOStuff::unserialize |
( |
|
$string, |
|
|
|
$default, |
|
|
array |
$loggingContext |
|
) |
| |
|
private |
- Parameters
-
string | $string | |
mixed | $default | |
array | $loggingContext | |
- Returns
- mixed
- Exceptions
-
◆ $inner
Wikibase\Lib\SimpleCacheWithBagOStuff::$inner |
|
private |
◆ $prefix
Wikibase\Lib\SimpleCacheWithBagOStuff::$prefix |
|
private |
◆ $secret
Wikibase\Lib\SimpleCacheWithBagOStuff::$secret |
|
private |
◆ INVALID_KEY_REGEX
const Wikibase\Lib\SimpleCacheWithBagOStuff::INVALID_KEY_REGEX = '/[\{\}\(\)\/\\\\@:]/' |
|
private |
The documentation for this class was generated from the following file: