Amp\Cache\ArrayCache class ArrayCache implements Amp\Cache\Cache

Summary

Properties

Methods

Properties

Methods

__construct — public function __construct(int $gcInterval = 5000)

By using a rebound TTL watcher with a shared state object we're able to use __destruct() for "normal" garbage collection of both this instance and the reactor watcher callback. Otherwise this object could only be GC'd when the TTL watcher was cancelled at the event reactor layer.

Type Parameter Description Default Value
int $gcInterval The frequency in milliseconds at which expired cache entries should be garbage collected 5000
__destruct — public function __destruct()
No documentation.
get — public function get($key)

Gets a value associated with the given key.

If the specified key doesn't exist implementations MUST succeed the resulting promise with NULL.

Type Parameter Description Default Value
mixed $key string none
set — public function set($key, $value, $ttl = null)

Sets a value associated with the given key. Overrides existing values (if they exist).

Implementations MUST NOT accept NULL as value as it's reserved for missing values and should not have any other meaning. TTL values are measured in seconds.

The default NULL $ttl value indicates no timeout.

The eventual resolution value of the resulting promise is unimportant. The success or failure of the promise indicates the operation's success.

Type Parameter Description Default Value
mixed $key string none
mixed $value string none
mixed $ttl int null
del — public function del($key)

Deletes a value associated with the given key if it exists.

The eventual resolution value of the resulting promise is unimportant. However, implementations SHOULD return boolean TRUE or FALSE to indicate if the specified key existed at the time the delete operation was request.

The ultimate success or failure of the promise indicates the operation's success, though. Implementations MUST transparently succeed operations for non-existent keys.

Type Parameter Description Default Value
mixed $key string none