ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
PhpOffice\PhpSpreadsheet\Collection\Memory Class Reference

This is the default implementation for in-memory cell collection. More...

+ Inheritance diagram for PhpOffice\PhpSpreadsheet\Collection\Memory:
+ Collaboration diagram for PhpOffice\PhpSpreadsheet\Collection\Memory:

Public Member Functions

 clear ()
 Wipes clean the entire cache's keys. More...
 
 delete ($key)
 Delete an item from the cache by its unique key. More...
 
 deleteMultiple ($keys)
 Deletes multiple cache items in a single operation. More...
 
 get ($key, $default=null)
 Fetches a value from the cache. More...
 
 getMultiple ($keys, $default=null)
 Obtains multiple cache items by their unique keys. More...
 
 has ($key)
 Determines whether an item is present in 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...
 
 setMultiple ($values, $ttl=null)
 Persists a set of key => value pairs in the cache, with an optional TTL. More...
 
 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...
 

Private Attributes

 $cache = []
 

Detailed Description

This is the default implementation for in-memory cell collection.

Alternatives implementation should leverage off-memory, non-volatile storage to reduce overall memory usage.

Definition at line 13 of file Memory.php.

Member Function Documentation

◆ clear()

PhpOffice\PhpSpreadsheet\Collection\Memory::clear ( )

Wipes clean the entire cache's keys.

Returns
bool True on success and false on failure.

Implements Psr\SimpleCache\CacheInterface.

Definition at line 17 of file Memory.php.

18 {
19 $this->cache = [];
20
21 return true;
22 }

◆ delete()

PhpOffice\PhpSpreadsheet\Collection\Memory::delete (   $key)

Delete an item from the cache by its unique key.

Parameters
string$keyThe unique cache key of the item to delete.
Returns
bool True if the item was successfully removed. False if there was an error.
Exceptions

Psr\SimpleCache\InvalidArgumentException MUST be thrown if the $key string is not a legal value.

Implements Psr\SimpleCache\CacheInterface.

Definition at line 24 of file Memory.php.

25 {
26 unset($this->cache[$key]);
27
28 return true;
29 }
$key
Definition: croninfo.php:18

References $key.

◆ deleteMultiple()

PhpOffice\PhpSpreadsheet\Collection\Memory::deleteMultiple (   $keys)

Deletes multiple cache items in a single operation.

Parameters
iterable$keysA list of string-based keys to be deleted.
Returns
bool True if the items were successfully removed. False if there was an error.
Exceptions

Psr\SimpleCache\InvalidArgumentException MUST be thrown if $keys is neither an array nor a Traversable, or if any of the $keys are not a legal value.

Implements Psr\SimpleCache\CacheInterface.

Definition at line 31 of file Memory.php.

32 {
33 foreach ($keys as $key) {
34 $this->delete($key);
35 }
36
37 return true;
38 }
$keys

References $key, and $keys.

◆ get()

PhpOffice\PhpSpreadsheet\Collection\Memory::get (   $key,
  $default = null 
)

Fetches a value from the cache.

Parameters
string$keyThe unique key of this item in the cache.
mixed$defaultDefault 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

Psr\SimpleCache\InvalidArgumentException MUST be thrown if the $key string is not a legal value.

Implements Psr\SimpleCache\CacheInterface.

Definition at line 40 of file Memory.php.

41 {
42 if ($this->has($key)) {
43 return $this->cache[$key];
44 }
45
46 return $default;
47 }
$default
Definition: build.php:20
has($key)
Determines whether an item is present in the cache.
Definition: Memory.php:59

References $default, $key, and PhpOffice\PhpSpreadsheet\Collection\Memory\has().

+ Here is the call graph for this function:

◆ getMultiple()

PhpOffice\PhpSpreadsheet\Collection\Memory::getMultiple (   $keys,
  $default = null 
)

Obtains multiple cache items by their unique keys.

Parameters
iterable$keysA list of keys that can obtained in a single operation.
mixed$defaultDefault 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

Psr\SimpleCache\InvalidArgumentException MUST be thrown if $keys is neither an array nor a Traversable, or if any of the $keys are not a legal value.

Implements Psr\SimpleCache\CacheInterface.

Definition at line 49 of file Memory.php.

50 {
51 $results = [];
52 foreach ($keys as $key) {
53 $results[$key] = $this->get($key, $default);
54 }
55
56 return $results;
57 }
$results
Definition: svg-scanner.php:47

References $default, $key, $keys, and $results.

◆ has()

PhpOffice\PhpSpreadsheet\Collection\Memory::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$keyThe cache item key.
Returns
bool
Exceptions

Psr\SimpleCache\InvalidArgumentException MUST be thrown if the $key string is not a legal value.

Implements Psr\SimpleCache\CacheInterface.

Definition at line 59 of file Memory.php.

60 {
61 return array_key_exists($key, $this->cache);
62 }

References $key.

Referenced by PhpOffice\PhpSpreadsheet\Collection\Memory\get().

+ Here is the caller graph for this function:

◆ set()

PhpOffice\PhpSpreadsheet\Collection\Memory::set (   $key,
  $value,
  $ttl = null 
)

Persists data in the cache, uniquely referenced by a key with an optional expiration TTL time.

Parameters
string$keyThe key of the item to store.
mixed$valueThe value of the item to store, must be serializable.
null | int | \DateInterval$ttlOptional. 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

Psr\SimpleCache\InvalidArgumentException MUST be thrown if the $key string is not a legal value.

Implements Psr\SimpleCache\CacheInterface.

Definition at line 64 of file Memory.php.

65 {
66 $this->cache[$key] = $value;
67
68 return true;
69 }

References $key.

◆ setMultiple()

PhpOffice\PhpSpreadsheet\Collection\Memory::setMultiple (   $values,
  $ttl = null 
)

Persists a set of key => value pairs in the cache, with an optional TTL.

Parameters
iterable$valuesA list of key => value pairs for a multiple-set operation.
null | int | \DateInterval$ttlOptional. 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

Psr\SimpleCache\InvalidArgumentException MUST be thrown if $values is neither an array nor a Traversable, or if any of the $values are not a legal value.

Implements Psr\SimpleCache\CacheInterface.

Definition at line 71 of file Memory.php.

72 {
73 foreach ($values as $key => $value) {
74 $this->set($key, $value);
75 }
76
77 return true;
78 }
$values

References $key, and $values.

Field Documentation

◆ $cache

PhpOffice\PhpSpreadsheet\Collection\Memory::$cache = []
private

Definition at line 15 of file Memory.php.


The documentation for this class was generated from the following file: