phpscript

manual

Class Go

SharedMemory

Description

SharedMemory returns the store the host bound into the runtime context, and a store of its own when the host bound none. No command in this tree binds one and `new SharedMemory` holds nothing across requests until an embedding host adds SharedMemoryContext.

SharedMemory is a class phpscript declares.

$object = new SharedMemory();

Methods

public function clear(): void

clear resets all keys and counters.

The go method Clear.

public function count(string $key): string

count returns a counter as a formatted string.

The go method Count.

public function delete(string $key): bool

delete removes a key from storage.

The go method Delete.

public function get(string $key): string

get retrieves a string value by key, or returns empty string if missing.

The go method Get.

public function has(string $key): bool

has checks if a key exists in data or counters.

The go method Has.

public function incr(string $key): int

incr atomically increments and returns a counter.

The go method Incr.

public function set(string $key, string $value): void

set stores a string value.

The go method Set.

public function usage(): array

usage reports what the store holds: how many entries, how many counters, and the bytes of the keys and values behind them.

The byte figure is the strings themselves, not the map overhead around them, which is the same basis memory_get_usage() reports a PHP value on.

The go method Usage.

Binding

See also