DiscordPHP Documentation

CacheWrapper
in package

Wrapper for CacheInterface that store Repository items.

Compatible with react/cache 0.5 - 1.x and psr/simple-cache interface.

Tags
since
10.0.0

Table of Contents

$config  : CacheConfig
$interface  : CacheInterface|CacheInterface
$class  : string
The item class name reference.
$config  : CacheConfig
Cache configuration.
$discord  : Discord
$interface  : CacheInterface|CacheInterface
$items  : array<string|int, ?\Discord\Parts\Part>|array<string|int, WeakReference>
Repository items array reference.
$prefix  : string
Cache key prefix.
__destruct()  : mixed
__get()  : mixed
clear()  : PromiseInterface<string|int, bool>
Clear all Parts from cache.
delete()  : PromiseInterface<string|int, bool>|bool
Delete Part from cache.
deleteMultiple()  : PromiseInterface<string|int, bool>
Delete multiple Parts from cache.
get()  : PromiseInterface<string|int, Part>
Get Part from cache.
getMultiple()  : PromiseInterface<string|int, array<string|int, mixed>>
Get multiple Parts from cache.
getPrefix()  : string
Get the cache key prefix.
has()  : PromiseInterface<string|int, bool>
Check if Part is present in cache.
serializer()  : object|string
set()  : PromiseInterface<string|int, bool>
Set Part into cache.
setMultiple()  : PromiseInterface<string|int, bool>
Set multiple Parts into cache.
sweep()  : int
Flush deleted items from cache and weaken items. Items with Bot's ID are exempt.
unserializer()  : Part|null
isZlibCompressed()  : bool
Checks if a value is zlib compressed by checking the magic bytes.

Properties

$interface read-only

public CacheInterface|CacheInterface $interface

The actual ReactPHP PSR-16 CacheInterface.

$class

The item class name reference.

protected string $class

$interface

protected CacheInterface|CacheInterface $interface

$items

Repository items array reference.

protected array<string|int, ?\Discord\Parts\Part>|array<string|int, WeakReference> $items

Cache Key => Cache Part.

Methods

__destruct()

public __destruct() : mixed
Return values
mixed

__get()

public __get(string $name) : mixed
Parameters
$name : string
Return values
mixed

clear()

Clear all Parts from cache.

public clear() : PromiseInterface<string|int, bool>

For react/cache 0.5 polyfill.

Return values
PromiseInterface<string|int, bool>

delete()

Delete Part from cache.

public delete(string $key) : PromiseInterface<string|int, bool>|bool
Parameters
$key : string
Return values
PromiseInterface<string|int, bool>|bool

deleteMultiple()

Delete multiple Parts from cache.

public deleteMultiple(array<string|int, mixed> $keys) : PromiseInterface<string|int, bool>

For react/cache 0.5 polyfill.

Parameters
$keys : array<string|int, mixed>
Return values
PromiseInterface<string|int, bool>

get()

Get Part from cache.

public get(string $key[, mixed $default = null ]) : PromiseInterface<string|int, Part>
Parameters
$key : string
$default : mixed = null
Return values
PromiseInterface<string|int, Part>

getMultiple()

Get multiple Parts from cache.

public getMultiple(array<string|int, mixed> $keys[, Part|null $default = null ]) : PromiseInterface<string|int, array<string|int, mixed>>

For react/cache 0.5 polyfill.

Parameters
$keys : array<string|int, mixed>
$default : Part|null = null
Return values
PromiseInterface<string|int, array<string|int, mixed>>

getPrefix()

Get the cache key prefix.

public getPrefix() : string
Return values
string

has()

Check if Part is present in cache.

public has(string $key) : PromiseInterface<string|int, bool>

For react/cache 0.5 polyfill.

Parameters
$key : string
Return values
PromiseInterface<string|int, bool>

serializer()

public serializer(Part $part) : object|string
Parameters
$part : Part
Return values
object|string

set()

Set Part into cache.

public set(string $key, Part $value[, mixed $ttl = null ]) : PromiseInterface<string|int, bool>
Parameters
$key : string
$value : Part
$ttl : mixed = null
Return values
PromiseInterface<string|int, bool>

setMultiple()

Set multiple Parts into cache.

public setMultiple(array<string|int, Part$values[, int|null $ttl = null ]) : PromiseInterface<string|int, bool>

For react/cache 0.5 polyfill.

Parameters
$values : array<string|int, Part>
$ttl : int|null = null
Return values
PromiseInterface<string|int, bool>

sweep()

Flush deleted items from cache and weaken items. Items with Bot's ID are exempt.

public sweep() : int
Return values
int

Flushed items.

unserializer()

public unserializer(string $value) : Part|null
Parameters
$value : string
Return values
Part|null

isZlibCompressed()

Checks if a value is zlib compressed by checking the magic bytes.

protected isZlibCompressed(string $data) : bool
Parameters
$data : string

The data to check.

Tags
link
https://www.rfc-editor.org/rfc/rfc1950
since
10.0.0
Return values
bool

whether it's zlib compressed data or not.

Search results