Amp\Cache\Cache interface Cache

Summary

Properties

Methods

Methods

get — public function get($key): Amp\Promise

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): Amp\Promise

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): Amp\Promise

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