Documentation

Repository extends CacheInterface

Table of Contents

add()  : bool
Store an item in the cache if the key does not exist.
clear()  : bool
Wipes clean the entire cache's keys.
decrement()  : int|bool
Decrement the value of an item in the cache.
delete()  : bool
Delete an item from the cache by its unique key.
deleteMultiple()  : bool
Deletes multiple cache items in a single operation.
forever()  : void
Store an item in the cache indefinitely.
forget()  : bool
Remove an item from the cache.
get()  : mixed
Retrieve an item from the cache by key.
getMultiple()  : iteratable<string|int, mixed>
Obtains multiple cache items by their unique keys.
getStore()  : Store
Get the cache store implementation.
has()  : bool
Determine if an item exists in the cache.
increment()  : int|bool
Increment the value of an item in the cache.
pull()  : mixed
Retrieve an item from the cache and delete it.
put()  : void
Store an item in the cache.
remember()  : mixed
Get an item from the cache, or store the default value.
rememberForever()  : mixed
Get an item from the cache, or store the default value forever.
sear()  : mixed
Get an item from the cache, or store the default value forever.
set()  : bool
Persists data in the cache, uniquely referenced by a key with an optional expiration TTL time.
setMultiple()  : bool
Persists a set of key => value pairs in the cache, with an optional TTL.

Methods

add()

Store an item in the cache if the key does not exist.

public add(string $key, mixed $value, DateTimeInterface|DateInterval|float|int $minutes) : bool
Parameters
$key : string
$value : mixed
$minutes : DateTimeInterface|DateInterval|float|int
Return values
bool

clear()

Wipes clean the entire cache's keys.

public clear() : bool
Return values
bool

True on success and false on failure.

decrement()

Decrement the value of an item in the cache.

public decrement(string $key[, mixed $value = 1 ]) : int|bool
Parameters
$key : string
$value : mixed = 1
Return values
int|bool

delete()

Delete an item from the cache by its unique key.

public delete(string $key) : bool
Parameters
$key : string

The unique cache key of the item to delete.

Tags
throws
InvalidArgumentException

MUST be thrown if the $key string is not a legal value.

Return values
bool

True if the item was successfully removed. False if there was an error.

deleteMultiple()

Deletes multiple cache items in a single operation.

public deleteMultiple(iteratable<string|int, mixed> $keys) : bool
Parameters
$keys : iteratable<string|int, mixed>

A list of string-based keys to be deleted.

Tags
throws
InvalidArgumentException

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

Return values
bool

True if the items were successfully removed. False if there was an error.

forever()

Store an item in the cache indefinitely.

public forever(string $key, mixed $value) : void
Parameters
$key : string
$value : mixed
Return values
void

forget()

Remove an item from the cache.

public forget(string $key) : bool
Parameters
$key : string
Return values
bool

get()

Retrieve an item from the cache by key.

public get(string $key[, mixed $default = null ]) : mixed
Parameters
$key : string
$default : mixed = null
Return values
mixed

getMultiple()

Obtains multiple cache items by their unique keys.

public getMultiple(iteratable<string|int, mixed> $keys[, mixed $default = null ]) : iteratable<string|int, mixed>
Parameters
$keys : iteratable<string|int, mixed>

A list of keys that can obtained in a single operation.

$default : mixed = null

Default value to return for keys that do not exist.

Tags
throws
InvalidArgumentException

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

Return values
iteratable<string|int, mixed>

A list of key => value pairs. Cache keys that do not exist or are stale will have $default as value.

has()

Determine if an item exists in the cache.

public has(string $key) : bool
Parameters
$key : string
Return values
bool

increment()

Increment the value of an item in the cache.

public increment(string $key[, mixed $value = 1 ]) : int|bool
Parameters
$key : string
$value : mixed = 1
Return values
int|bool

pull()

Retrieve an item from the cache and delete it.

public pull(string $key[, mixed $default = null ]) : mixed
Parameters
$key : string
$default : mixed = null
Return values
mixed

put()

Store an item in the cache.

public put(string $key, mixed $value, DateTimeInterface|DateInterval|float|int $minutes) : void
Parameters
$key : string
$value : mixed
$minutes : DateTimeInterface|DateInterval|float|int
Return values
void

remember()

Get an item from the cache, or store the default value.

public remember(string $key, DateTimeInterface|DateInterval|float|int $minutes, Closure $callback) : mixed
Parameters
$key : string
$minutes : DateTimeInterface|DateInterval|float|int
$callback : Closure
Return values
mixed

rememberForever()

Get an item from the cache, or store the default value forever.

public rememberForever(string $key, Closure $callback) : mixed
Parameters
$key : string
$callback : Closure
Return values
mixed

sear()

Get an item from the cache, or store the default value forever.

public sear(string $key, Closure $callback) : mixed
Parameters
$key : string
$callback : Closure
Return values
mixed

set()

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

public set(string $key, mixed $value[, null|int|DateInterval $ttl = null ]) : bool
Parameters
$key : string

The key of the item to store.

$value : mixed

The value of the item to store, must be serializable.

$ttl : null|int|DateInterval = null

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.

Tags
throws
InvalidArgumentException

MUST be thrown if the $key string is not a legal value.

Return values
bool

True on success and false on failure.

setMultiple()

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

public setMultiple(iteratable<string|int, mixed> $values[, null|int|DateInterval $ttl = null ]) : bool
Parameters
$values : iteratable<string|int, mixed>

A list of key => value pairs for a multiple-set operation.

$ttl : null|int|DateInterval = null

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.

Tags
throws
InvalidArgumentException

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

Return values
bool

True on success and false on failure.

Search results