Allows to cache output fragments, PHP data or raw data to a Aerospike backend.
use Phalcon\Cache\Frontend\Data;
use Phalcon\Cache\Backend\Aerospike as CacheBackend;
Cache data for 2 days
$frontCache = new Data(['lifetime' => 172800]);
Create the Cache setting redis connection options
$cache = new CacheBackend($frontCache, [
'hosts' => [
['addr' => '127.0.0.1', 'port' => 3000]
],
'persistent' => true,
'namespace' => 'test',
'prefix' => 'cache_',
'options' => [
\Aerospike::OPT_CONNECT_TIMEOUT => 1250,
\Aerospike::OPT_WRITE_TIMEOUT => 1500
]
]);
Cache arbitrary data
$cache->save('my-data', [1, 2, 3, 4, 5]);
Get data
$data = $cache->get('my-data');