yangyao / shm-cache
yet another php shm cache
dev-master
2019-04-16 07:33 UTC
Requires
- ext-shmop: *
Requires (Dev)
- phpunit/phpunit: 7.5.x-dev
This package is auto-updated.
Last update: 2025-01-17 17:11:30 UTC
README
yet another php cache based on share memory
how to use ?
install var composer
composer require yangyao/shm-cache
basic use .
$shm = new Yangyao\ShmCache\ShmHashMap(); $shm->create(0x2222); $shm->set('hello','world'); $shm->get('hello');
master and salver
$masterKey = 0x2222; $salverKey = 0x2223; $key = 'hello'; // add key to master $shmMaster = new Yangyao\ShmCache\ShmHashMap(); $shmMaster->create($masterKey); $shmMaster->set('hello','world'); // add key to salver $shmSalver = new Yangyao\ShmCache\ShmHashMap(); $shmSalver->create($salverKey); $shmSalver->set('hello','world'); // use the reader Yangyao\ShmCache\Reader::init($masterKey,$salverKey); Yangyao\ShmCache\Reader::get($key);
cluster consistent
$server_1 = 0x2222; $server_2 = 0x2223; $key = 'hello'; $consistent = new Yangyao\ShmCache\ConsistentHash(); $consistent->addServer($server_1); $consistent->addServer($server_2); $server = $consistent->find($key); $shm = new Yangyao\ShmCache\ShmHashMap(); $shm->attach($server); // $shm->set($key,'world'); $data = $shm->get($key);
what's the principle ?
- based on hash arithmetic
- write data into share memory use php shmop extension
what's the data structure ?
head
data
all