1. Go to this page and download the library: Download laruence/yac library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
laruence / yac example snippets
YAC_VERSION
YAC_MAX_KEY_LEN = 48
; If your key is longer than 48 bytes, consider using md5() of the key instead.
YAC_MAX_VALUE_RAW_LEN = 67108863 ; (1 << 26) - 1
YAC_MAX_RAW_COMPRESSED_LEN = 1048576 ; 1M in bytes
YAC_SERIALIZER_PHP = 0 ; always available, since Yac 2.2.0
; The following are only defined when the corresponding serializer is compiled in:
YAC_SERIALIZER_JSON = 1 ;
$yac->set("f", false);
var_dump($yac->get("f")); // bool(false) — the stored value
var_dump($yac->get("missing")); // bool(false) — a miss, same shape
var_dump($yac->get("f", "__NONE__")); // bool(false) — the stored value
var_dump($yac->get("missing", "__NONE__")); // string(8) "__NONE__" — the default
Yac::__construct([string $prefix = ""])
$yac = new Yac("myproduct_");
// Two instances sharing the same memory pool but with isolated key namespaces:
$userCache = new Yac("user_");
$sysCache = new Yac("sys_");
$userCache->set("123", $userData); // actual key: "user_123"
$sysCache->set("config", $config); // actual key: "sys_config"
$yac = new Yac();
$yac->foo = "bar"; // equivalent to $yac->set("foo", "bar")
echo $yac->foo; // equivalent to $yac->get("foo")
unset($yac->foo); // equivalent to $yac->delete("foo")
Yac::add(string $key, mixed $value[, int $ttl = 0]): bool
Yac::add(array $kvs[, int $ttl = 0]): bool