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');
显示文件
Open project: phalcon/incubator
Class Usage Examples
Property | Type | Description | |
---|---|---|---|
$db | The Aerospike DB | ||
$namespace | string | Default Aerospike namespace | |
$set | string | The Aerospike Set for store cache |
Method | Description | |
---|---|---|
__construct ( Phalcon\Cache\FrontendInterface $frontend, array $options ) | Phalcon\Cache\Backend\Aerospike constructor | |
decrement ( string $keyName = null, integer $value = null ) : integer | false | Decrement of $keyName by given $value | |
delete ( integer | string $keyName ) : boolean | ||
exists ( string $keyName = null, integer $lifetime = null ) : boolean | ||
get ( integer | string $keyName, integer $lifetime = null ) : mixed | ||
getDb ( ) : |
Gets the Aerospike instance. | |
increment ( string $keyName = null, integer $value = null ) : integer | false | Increment of given $keyName by $value | |
queryKeys ( string $prefix = null ) : array | ||
save ( integer | string $keyName = null, string $content = null, integer $lifetime = null, boolean $stopBuffer = true ) : boolean |
Method | Description | |
---|---|---|
buildKey ( string $key ) : array | Generates a unique key used for storing cache data in Aerospike DB. |
public __construct ( Phalcon\Cache\FrontendInterface $frontend, array $options ) | ||
$frontend | Phalcon\Cache\FrontendInterface | Frontend Interface |
$options | array | Constructor options |
protected Aerospike,Phalcon\Cache\Backend $db | ||
return |
protected string $namespace | ||
return | string |