yet another php cache based on share memory
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);
- based on hash arithmetic
- write data into share memory use php shmop extension
head
data
all