本文整理汇总了PHP中Redis::del方法的典型用法代码示例。如果您正苦于以下问题:PHP Redis::del方法的具体用法?PHP Redis::del怎么用?PHP Redis::del使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Redis
的用法示例。
在下文中一共展示了Redis::del方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: del
public function del($key)
{
if (!$this->isConnected()) {
return false;
}
return (bool) $this->redis->del($key);
}
示例2: get
public function get($key, $top = 10)
{
$result_key = $this->result_prefix . $key;
$this->redis->zInter($result_key, [$this->key_prefix . $key, $this->word_prefix], [1, 1]);
$result = $this->redis->zRevRange($result_key, 0, $top, true);
$this->redis->del($result_key);
return $result;
}
示例3: releaseLock
/**
* {@inheritdoc}
*/
public function releaseLock($name)
{
if (isset($this->locks[$name]) && $this->redis->del($name)) {
$this->clearLock($name);
return true;
}
return false;
}
示例4: clear
public function clear()
{
$this->redis->setOption(\Redis::OPT_SERIALIZER, \Redis::SERIALIZER_NONE);
$prefix = $this->redis->getOption(\Redis::OPT_PREFIX);
$offset = strlen($prefix);
$keys = $this->redis->keys('*');
foreach ($keys as $key) {
$this->redis->del(substr($key, $offset));
}
}
示例5: disable_feature
/**
* Disable a dark launch feature
* @param $feature string - The name of the feature
*/
public function disable_feature($feature_name)
{
$multi = $this->redis->multi();
$this->redis->del("{$this->feature_namespace()}:feature:{$feature_name}");
$this->redis->srem("{$this->feature_namespace()}:features", $feature_name);
$multi->exec();
}
示例6: tearDown
/**
* Delete the keys that were added to the database during the test
*/
public function tearDown()
{
parent::tearDown();
Redis::del($this->testingResource->testModelHashId);
Redis::del($this->testingResource->testModelSearchableId);
Redis::del("testmodels");
}
示例7: release_lock
/**
* Releases a given lock if the owner information matches.
*
* @see cache_is_lockable
* @param string $key Name of the lock to release.
* @param string $ownerid Owner information to use.
* @return bool True if the lock is released, false if it is not.
*/
public function release_lock($key, $ownerid)
{
if ($this->check_lock_state($key, $ownerid)) {
return $this->redis->del($key) !== false;
}
return false;
}
示例8: unlock
public function unlock()
{
try {
$this->rd->del($this->k);
} catch (\RedisException $e) {
}
}
示例9: unlock
private function unlock()
{
if ($this->locked) {
$this->redis->del($this->lockKey);
$this->locked = false;
}
}
示例10: removeWord
/**
* {@inheritDoc}
*/
public function removeWord($language, $word)
{
$word = mb_strtolower($word, mb_detect_encoding($word));
if ($this->redis->exists($word)) {
$languages = unserialize($this->redis->get($word));
if (false !== ($index = array_search($language, $languages))) {
unset($languages[$index]);
if (!count($languages)) {
$this->redis->del($word);
} else {
$this->redis->set($word, serialize($languages));
}
}
}
return $this;
}
示例11: flush
/**
* Deletes all items from cache.
*
* This should only be used for maintenance purposes (slow performance).
*/
public function flush()
{
$keys = $this->redis->keys($this->redis->prefix('*'));
foreach ($keys as $key) {
$this->redis->del($key);
}
}
示例12: testUnserialize
public function testUnserialize()
{
$vals = array(1, 1.5, 'one', array('this', 'is', 'an', 'array'));
$serializers = array(Redis::SERIALIZER_PHP);
if (defined('Redis::SERIALIZER_IGBINARY')) {
$serializers[] = Redis::SERIALIZER_IGBINARY;
}
foreach ($serializers as $mode) {
$vals_enc = array();
// Pass them through redis so they're serialized
foreach ($vals as $key => $val) {
$this->redis->setOption(Redis::OPT_SERIALIZER, $mode);
$key = "key" . ++$key;
$this->redis->del($key);
$this->redis->set($key, $val);
// Clear serializer, get serialized value
$this->redis->setOption(Redis::OPT_SERIALIZER, Redis::SERIALIZER_NONE);
$vals_enc[] = $this->redis->get($key);
}
// Run through our array comparing values
for ($i = 0; $i < count($vals); $i++) {
// reset serializer
$this->redis->setOption(Redis::OPT_SERIALIZER, $mode);
$this->assertTrue($vals[$i] == $this->redis->_unserialize($vals_enc[$i]));
$this->redis->setOption(Redis::OPT_SERIALIZER, Redis::SERIALIZER_NONE);
}
}
}
示例13: destroy
/**
* Destroy a session.
* Expects a session id.
* @param string $sessionId
* @return boolean
*/
public function destroy($sessionId = '')
{
if ($sessionId !== '' && $this->_redis->exists($this->_key($sessionId))) {
$this->_redis->del($this->_key($sessionId));
}
session_destroy();
return true;
}
示例14: remove
public function remove()
{
if (!$this->id) {
return false;
}
Redis::del($this->key());
Redis::zrem(get_class($this), $this->id);
}
示例15: clear
protected static function clear(\Redis $redis)
{
$prefix = $redis->getOption(\Redis::OPT_PREFIX);
$offset = strlen($prefix);
$keys = $redis->keys('*');
foreach ($keys as $key) {
$redis->del(substr($key, $offset));
}
}