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');
파일 보기
프로젝트 열기: phalcon/incubator
1 사용 예제들
프로퍼티 | 타입 | 설명 | |
---|---|---|---|
$db | The Aerospike DB | ||
$namespace | string | Default Aerospike namespace | |
$set | string | The Aerospike Set for store cache |
메소드 | 설명 | |
---|---|---|
__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 |
메소드 | 설명 | |
---|---|---|
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 |