本文整理汇总了PHP中Predis\Client::expireat方法的典型用法代码示例。如果您正苦于以下问题:PHP Client::expireat方法的具体用法?PHP Client::expireat怎么用?PHP Client::expireat使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Predis\Client
的用法示例。
在下文中一共展示了Client::expireat方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: store
/**
* @param Password $password
* @param bool $allowOverwrite
*/
public function store(Password $password, $allowOverwrite = false)
{
if (!$allowOverwrite && $this->get($password->getId())) {
throw new PhPsstException('The ID already exists', PhPsstException::ID_IS_ALREADY_TAKEN);
}
$this->client->set($password->getId(), $password->getJson());
$this->client->expireat($password->getId(), $password->getTtl());
}
示例2: expireIn
public function expireIn($key, $seconds)
{
$redisTime = $this->client->time();
$at = ceil($redisTime[0] + $seconds);
$this->client->expireat($this->prefixTimestamp($key), $at);
return (int) $this->client->expireat($this->prefixKey($key), $at) === 1;
}
示例3: storeAssociation
/**
* Store association until its expiration time in Redis server.
* Overwrites any existing association with same server_url and
* handle. Handles list of associations for every server.
*/
function storeAssociation($server_url, $association)
{
// create Redis keys for association itself
// and list of associations for this server
$associationKey = $this->associationKey($server_url, $association->handle);
$serverKey = $this->associationServerKey($server_url);
// save association to server's associations' keys list
$this->redis->lpush($serverKey, $associationKey);
// Will touch the association list expiration, to avoid filling up
$newExpiration = $association->issued + $association->lifetime;
$expirationKey = $serverKey . '_expires_at';
$expiration = $this->redis->get($expirationKey);
if (!$expiration || $newExpiration > $expiration) {
$this->redis->set($expirationKey, $newExpiration);
$this->redis->expireat($serverKey, $newExpiration);
$this->redis->expireat($expirationKey, $newExpiration);
}
// save association itself, will automatically expire
$this->redis->setex($associationKey, $newExpiration - time(), serialize($association));
}
示例4: flush
/**
*
*/
public function flush()
{
$this->client->transaction(function () {
foreach ($this->buffer as $name => $options) {
$ttl = $this->client->ttl($name);
$exists = $this->client->exists($name);
$this->client->set($name, $options['value']);
if ($options['expire'] > 0) {
$this->client->expire($name, $options['expire']);
}
if ($options['expire'] < 0) {
if (!$exists || $ttl < 0) {
$this->client->expireat($name, time() + $options['expire'] * -1);
} else {
$this->client->expire($name, $ttl);
}
}
}
});
}