All Projects → laruence → Yac

laruence / Yac

Licence: other
A fast, lock-free, shared memory user data cache for PHP

Programming Languages

c
50402 projects - #5 most used programming language

Projects that are alternatives of or similar to Yac

Libshmcache
libshmcache is a local cache in the share memory for multi processes. high performance due to read is lockless. libshmcache is 100+ times faster than a remote interface such as redis.
Stars: ✭ 385 (-50.77%)
Mutual labels:  cache, shared-memory
Traffic Shm
traffic-shm (Anna) is a Java based lock free IPC library.
Stars: ✭ 72 (-90.79%)
Mutual labels:  lock-free, shared-memory
Httpcache
A Transport for http.Client that will cache responses according to the HTTP RFC
Stars: ✭ 603 (-22.89%)
Mutual labels:  cache
React Native Img Cache
Image Cache for React Native
Stars: ✭ 724 (-7.42%)
Mutual labels:  cache
React Router Cache Route
Route with cache for React-Router like <keep-alive/> in Vue
Stars: ✭ 677 (-13.43%)
Mutual labels:  cache
Cache Loader
[DEPRECATED] Caches the result of following loaders on disk
Stars: ✭ 630 (-19.44%)
Mutual labels:  cache
Swiftcoroutine
Swift coroutines for iOS, macOS and Linux.
Stars: ✭ 690 (-11.76%)
Mutual labels:  lock-free
Flask Caching
A caching extension for Flask
Stars: ✭ 582 (-25.58%)
Mutual labels:  cache
Gocache
☔️ A complete Go cache library that brings you multiple ways of managing your caches
Stars: ✭ 775 (-0.9%)
Mutual labels:  cache
Reservoir
Android library to easily serialize and cache your objects to disk using key/value pairs.
Stars: ✭ 674 (-13.81%)
Mutual labels:  cache
Xmemcached
High performance, easy to use multithreaded memcached client in java.
Stars: ✭ 715 (-8.57%)
Mutual labels:  cache
Universal
Seed project for Angular Universal apps featuring Server-Side Rendering (SSR), Webpack, CLI scaffolding, dev/prod modes, AoT compilation, HMR, SCSS compilation, lazy loading, config, cache, i18n, SEO, and TSLint/codelyzer
Stars: ✭ 669 (-14.45%)
Mutual labels:  cache
Retrofitcache
RetrofitCache让retrofit2+okhttp3+rxjava配置缓存如此简单。通过注解配置,可以针对每一个接口灵活配置缓存策略;同时让每一个接口方便支持数据模拟,可以代码减小侵入性,模拟数据可以从内存,Assets,url轻松获取。
Stars: ✭ 647 (-17.26%)
Mutual labels:  cache
Offix
GraphQL Offline Client and Server
Stars: ✭ 694 (-11.25%)
Mutual labels:  cache
Boltons
🔩 Like builtins, but boltons. 250+ constructs, recipes, and snippets which extend (and rely on nothing but) the Python standard library. Nothing like Michael Bolton.
Stars: ✭ 5,671 (+625.19%)
Mutual labels:  cache
Rome
Carthage cache for S3, Minio, Ceph, Google Storage, Artifactory and many others
Stars: ✭ 724 (-7.42%)
Mutual labels:  cache
Axios Extensions
🍱 axios extensions lib, including throttle, cache, retry features etc...
Stars: ✭ 594 (-24.04%)
Mutual labels:  cache
Nebulex
In-memory and distributed caching toolkit for Elixir.
Stars: ✭ 662 (-15.35%)
Mutual labels:  cache
Ghostdb
GhostDB is a distributed, in-memory, general purpose key-value data store that delivers microsecond performance at any scale.
Stars: ✭ 690 (-11.76%)
Mutual labels:  cache
Smartsql
SmartSql = MyBatis in C# + .NET Core+ Cache(Memory | Redis) + R/W Splitting + PropertyChangedTrack +Dynamic Repository + InvokeSync + Diagnostics
Stars: ✭ 775 (-0.9%)
Mutual labels:  cache

Yac - Yet Another Cache

Build Status Build status Build Status

Yac is a shared and lockless memory user data cache for PHP.

it can be used to replace APC or local memcached.

Requirement

  • PHP 7 +

Install

$/path/to/phpize
$./configure --with-php-config=/path/to/php-config
$make && make install

Note

  1. Yac is a lockless cache, you should try to avoid or reduce the probability of multiple processes set one same key
  2. Yac use partial crc, you'd better re-arrange your cache content, place the most important(mutable) bytes at the head or tail

Restrictions

  1. Cache key cannot be longer than 48 (YAC_MAX_KEY_LEN) bytes
  2. Cache Value cannot be longer than 64M (YAC_MAX_VALUE_RAW_LEN) bytes
  3. Cache Value after compressed cannot be longer than 1M (YAC_MAX_VALUE_COMPRESSED_LEN) bytes

InIs

yac.enable = 1

yac.keys_memory_size = 4M ; 4M can get 30K key slots, 32M can get 100K key slots

yac.values_memory_size = 64M

yac.compress_threshold = -1

yac.enable_cli = 0 ; whether enable yac with cli, default 0

yac.serializer = php ; since yac 2.2.0 , specific seralizer yac used
                       could be json(--enable-json), msgpack(--enable-msgpack) or igbinary(--enable-igbinary)

Constants

YAC_VERSION

YAC_MAX_KEY_LEN = 48 ; if your key is longer than this, maybe you can use md5 result as the key

YAC_MAX_VALUE_RAW_LEN = 64M

YAC_MAX_VALUE_COMPRESSED_LEN = 1M

YAC_SERIALIZER_PHP = 0   ; since yac-2.2.0

YAC_SERIALIZER_JSON = 1  ; since yac-2.2.0

YAC_SERIALIZER_MSGPACK = 2 ; since yac-2.2.0

YAC_SERIALIZER_IGBINARY = 3 ; since yac-2.2.0

YAC_SERIALIZER  ; serializer according to yac.serializer, default is YAC_SERIALIZER_PHP

Methods

Yac::__construct

   Yac::__construct([string $prefix = ""])

Constructor of Yac, you can specify a prefix which will used to prepend to any keys when doing set/get/delete

<?php
   $yac = new Yac("myproduct_");
?>

Yac::set

   Yac::set($key, $value[, $ttl = 0])
   Yac::set(array $kvs[, $ttl = 0])

Store a value into Yac cache, keys are cache-unique, so storing a second value with the same key will overwrite the original value.

Return true on success, return false on error (Like no memory, can not obtain cas write right)

<?php
$yac = new Yac();
$yac->set("foo", "bar");
$yac->set(
    array(
        "dummy" => "foo",
        "dummy2" => "foo",
        )
    );
?>

Note:

As Yac 2.1, Store may failure if cas competition fails, you may need to do:

while (!($yac->set("important", "value")));

if you need the value to be stored properly.

Yac::get

   Yac::get(array|string $key[, &$cas = NULL])

Fetches a stored variable from the cache. If an array is passed then each element is fetched and returned.

Return the value on success, return false on error(Like no memory, can not obtain cas write right)

<?php
$yac = new Yac();
$yac->set("foo", "bar");
$yac->set(
    array(
        "dummy" => "foo",
        "dummy2" => "foo",
        )
    );
$yac->get("dummy");
$yac->get(array("dummy", "dummy2"));
?>

Yac::delete

   Yac::delete(array|string $keys[, $delay=0])

Removes a stored variable from the cache. If delay is specified, then the value will be deleted after $delay seconds.

Yac::flush

   Yac::flush()

Immediately invalidates all existing items. it doesn't actually free any resources, it only marks all the items as invalid.

Yac::info

   Yac::info(void)

Get cache info

<?php
  ....
  var_dump($yac->info());
  /* will return an array like:
  array(11) {
      ["memory_size"]=> int(541065216)
      ["slots_memory_size"]=> int(4194304)
      ["values_memory_size"]=> int(536870912)
      ["segment_size"]=> int(4194304)
      ["segment_num"]=> int(128)
      ["miss"]=> int(0)
      ["hits"]=> int(955)
      ["fails"]=> int(0)
      ["kicks"]=> int(0)
      ["slots_size"]=> int(32768)
      ["slots_used"]=> int(955)
  }
  */
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].