PHP 8.6.0 Beta 3 is available for testing

The Yac class

(PECL yac >= 1.0.0)

Introduction

The Yac class is the interface to the cache. Every instance on the same host is a lightweight handle to one shared cache: all instances read and write the same entries, and creating one does no allocation beyond the handle itself.

The optional prefix passed to Yac::__construct() is prepended to every key, so several instances (or applications) can share one cache without their keys colliding. Besides the classic cache operations (Yac::add(), Yac::set(), Yac::get(), Yac::delete() and Yac::flush()), the class provides Yac::info() and Yac::dump() for inspecting the cache, and overloads property access so that reading or writing an object property reads or writes a cache entry.

Class synopsis

class Yac {
/* Properties */
protected $_prefix;
/* Methods */
public function __construct(string $prefix = "")
public function add(string|array $key, mixed $value, int $ttl = 0): bool
public function add(array $values, int $ttl = 0): bool
public function delete(string|array $key, int $delay = 0): bool
public function dump(int $limit = 100, int $offset = 0): array
public function flush(): bool
public function get(string|array $key, mixed $default = null): mixed
public function __get(string $key): mixed
public function info(): array
public function set(string|array $key, mixed $value, int $ttl = 0): bool
public function set(array $values, int $ttl = 0): bool
public function __set(string $key, mixed $value): mixed
}

Properties

_prefix

The key prefix set through Yac::__construct(). It is prepended to every key used with the instance; no separator is inserted, so include one in the prefix when needed. The prefix may not exceed YAC_MAX_KEY_LEN (48) bytes.

Table of Contents

add a note

User Contributed Notes

There are no user contributed notes for this page.
To Top