PHP code example of takuya / php-sysv-ipc-shm-cache

1. Go to this page and download the library: Download takuya/php-sysv-ipc-shm-cache 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/ */

    

takuya / php-sysv-ipc-shm-cache example snippets



$cache = new SysvShmCache('cache_name');
$cache->set($key, $data);
$cache->has($key);
$cache->get($key);
$cache->delete($key);


$cache = new SysvShmCache($cache_name);
$key = 'key';
$cache->runWithLock(function($cache)use($key,$idx){
  $cache->set($key, $cache->get($key) + 10 );
});

// without locking, this can be dirty read.
$cache->set($key, $cache->get($key) + 10 );