laruence/yac
FreeA fast, lock-free, shared memory user data cache for PHP
About laruence/yac
Yac (Yet Another Cache) is a fast, lock-free, shared memory user data cache for PHP. It is designed to replace APC or local memcached. Yac stores key-value pairs in shared memory using a lockless algorithm, achieving high concurrency. It supports serialization via PHP, JSON, msgpack, or igbinary, and allows configuration of memory sizes for keys and values. Yac requires PHP 7+ and imposes limits: keys up to 48 bytes, raw values up to 64 MB, and compressed values up to 1 MB. It provides methods like Yac::set, Yac::get, and Yac::__construct with an optional key prefix. Due to its lockless nature, multiple processes modifying the same key may experience CAS competition; users should handle retries for critical writes.
Key Features
Pros & Cons
- Very fast due to lockless architecture
- Simple API similar to APC or memcached
- Completely free and open source (BSD-style license)
- Supports multiple serialization formats for flexibility
- Low memory overhead with configurable slot count
- Key length limited to 48 bytes
- Raw value limited to 64 MB, compressed value limited to 1 MB
- Lockless design can cause CAS competition if multiple processes write the same key
- No built-in replication or persistence (volatile shared memory)
- Requires careful key design to avoid CRC collisions (uses partial CRC)