本文整理汇总了PHP中Predis\ClientInterface::del方法的典型用法代码示例。如果您正苦于以下问题:PHP ClientInterface::del方法的具体用法?PHP ClientInterface::del怎么用?PHP ClientInterface::del使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Predis\ClientInterface
的用法示例。
在下文中一共展示了ClientInterface::del方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: release
/**
* Releases the lock, if it has not been released already
*/
public function release()
{
if ($this->released) {
return;
}
// Only release the lock if it hasn't expired
if ($this->expire >= time()) {
$this->redis->del($this->key);
}
$this->released = true;
}
示例2: removeIndexId
/**
* Remove an ID from an index
* @param string $id
* @param string $index
* @return void
*/
protected function removeIndexId(string $id, string $index)
{
if ($this->redis->scard($index) == 1) {
return $this->redis->del($index);
}
return $this->redis->srem($index, $id);
}
示例3: preRequestHandle
/**
* @param SessionInterface $session
* @param Request $request
*/
private function preRequestHandle(SessionInterface $session, Request $request)
{
$id = $request->cookie($this->key);
$key = 'session:' . $id;
if (!Str::equals($key, $session->getId())) {
$this->redis->del($key);
return;
}
$value = $this->redis->get('session:' . $key);
$content = Json::parse($value);
if ($content['last_seen'] > $session->get('last_seen')) {
foreach ($content as $key => $value) {
if (!Str::startsWith($key, ['_', 'login_'])) {
$session->set($key, $value);
}
}
}
}
示例4: release
/**
* Release the lock if we possess it.
*
* Returns true if we released the lock, and false if it was already
* released.
*
* @return bool
*/
public function release()
{
if (!$this->locked()) {
return false;
}
$this->redis->del($this->name);
$this->state = self::UNLOCKED;
return true;
}
示例5: clear
/**
* Delete all keys from the cache
*
* @param bool $check if true will check expiration, otherwise delete all
* @return bool True if the cache was successfully cleared, false otherwise
*/
public function clear($check)
{
if ($check) {
return true;
}
$keys = $this->client->keys($this->_config['prefix'] . '*');
foreach ($keys as $key) {
$this->client->del($key);
}
return true;
}
示例6: deleteGlob
private function deleteGlob($pattern)
{
$keys = $this->client->keys($pattern);
$options = $this->client->getOptions();
if (isset($options->prefix)) {
$length = strlen($options->prefix->getPrefix());
$keys = array_map(function ($key) use($length) {
return substr($key, $length);
}, $keys);
}
if (count($keys) === 0) {
return;
}
$this->client->del($keys);
}
示例7: testSet
/**
* @group redis-strings
*/
public function testSet()
{
$this->assertEquals('OK', $this->client->set('foo', 'bar'));
$this->assertEquals('OK', $this->client->set('foo', 'baz'));
$this->assertSame('baz', $this->client->get('foo'));
// EX expire time
$this->assertEquals('OK', $this->client->set('foo', 'bar', 'EX', 20));
$this->assertThat($this->client->ttl('foo'), $this->logicalAnd($this->greaterThan(0), $this->lessThanOrEqual(20)));
// PX expire time
$this->client->del('foo');
$this->assertEquals('OK', $this->client->set('foo', 'bar', 'PX', 20000));
$this->assertThat($this->client->ttl('foo'), $this->logicalAnd($this->greaterThan(0), $this->lessThanOrEqual(20)));
$this->client->del('foo');
$this->assertNull($this->client->set('foo', 'bar', 'XX'));
$this->assertEquals('OK', $this->client->set('foo', 'baz', 'NX'));
$this->assertNull($this->client->set('foo', 'blue', 'NX'));
$this->assertEquals('OK', $this->client->set('foo', 'red', 'XX'));
}
示例8: destroy
/**
* {@inheritdoc}
*/
public function destroy($sessionId)
{
$this->redis->del($sessionId);
return true;
}
示例9: doDelete
/**
* {@inheritdoc}
*/
protected function doDelete($id)
{
return $this->client->del($id) >= 0;
}
示例10: deleteMulti
/**
* @param array $keys
*
* @return void
*/
public function deleteMulti(array $keys)
{
$this->client->del($keys);
$this->addMultiDeleteAccessStats($keys);
}
示例11: del
/**
* {@inheritDoc}
*/
public function del($key)
{
return $this->predis->del($key);
}
示例12: destroy
/**
* Destroy Session - remove data from resource for
* given session id
* @param string $id
* @return void
*/
public function destroy($id)
{
$this->redisClient->del($id);
}