The Yac class

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

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

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