本文整理汇总了PHP中Redis::keys方法的典型用法代码示例。如果您正苦于以下问题:PHP Redis::keys方法的具体用法?PHP Redis::keys怎么用?PHP Redis::keys使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Redis
的用法示例。
在下文中一共展示了Redis::keys方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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));
}
}
示例2: o_indirect_tsf
/**
*@author: JJyy
*@todo: get the indirect transform number for the user_id
* less than 30 days
*@param:
*
**/
function o_indirect_tsf($user_id, $channel_name, $timeset, $db)
{
$sql = "select count(order_id) as cn from order_info where order_status=1 and pay_status=2 and confirm_time>" . $timeset . " and confirm_time<" . ($timeset + 3600 * 30);
$row = $db->query($sql);
$cn = $row['cn'];
if ($cn == 0) {
//if within 30 days no order
return 0;
} else {
$rds = new Redis();
//get the keys for the user_id
$keys = $rds->keys("*:" . $user_id);
//string like: li9t209jm7mc6m4vmn88o5a7j0:1454035403.8093:10.10.10.29:baidu:0
$num = 0;
foreach ($keys as $k => $v) {
//the time must after timeset
//same user_id and different channel_name and time after than timeset
if ($v[1] > $timeset && $v[3] != $channel_name && $v[4] == $user_id) {
$sql = "select count(order_id) as cn from order_info where order_status=1 and pay_status=2 and confirm_time>" . $timeset . " and confirm_time<" . ($timeset + 3600 * 2);
$row = $db->query($sql);
$cn = $row['cn'];
$num += $cn;
}
}
return $num;
}
}
示例3: r_indirect_tsf
/**
*@author: JJyy
*@todo: get the indirect user_id
*@param:
*@return:
*
**/
function r_indirect_tsf($sessid_arr)
{
$rds = new Redis();
$tmp = array();
$num = 0;
/**
* if get the keys is more than two, just check the second key user_id value
* if the value is 0, no reg, if not, registed
* every channel_name for every client( sessid ) just have one indirect_reg
* at most
**/
foreach ($sessid_arr as $k => $v) {
$tmp[] = $rds->keys($v . "*");
//two-dimemsion array
}
foreach ($tmp as $k => $v) {
if (count($v) > 1) {
//get the check time
$tmp_check_time = explode(':', $v[0]);
$check_time = $tmp_check_time[1];
$indirect_key = $v[1];
//the second key is indirect_key
//key like: li9t209jm7mc6m4vmn88o5a7j0:1454035403.8093:10.10.10.29:baidu:0
$key_arr = explode(':', $indirect_key);
if ($key_arr[4] != 0 && $key_arr[1] < $check_time + 3600 * 30) {
//the user_id !=0 and the time is less than 30 days
$num += 1;
}
}
}
//end foreach
return $num;
}
示例4: refresh
public static function refresh()
{
$posts = collect(self::wp_get('get_posts')['posts']);
$posts->each(function ($item) {
//delete all previous posts
if (\Config('cache.default') == 'redis') {
Redis::pipeline(function ($pipe) {
foreach (Redis::keys('laravel:a440:wordpress:posts_*') as $key) {
$pipe->del($key);
}
});
}
Cache::forever('a440:wordpress:posts_' . $item['id'], $item);
});
Cache::forever('a440:wordpress:posts', $posts->transform(function ($item) {
unset($item['content']);
unset($item['url']);
unset($item['status']);
unset($item['title_plain']);
unset($item['modified']);
unset($item['categories']);
unset($item['comments']);
unset($item['attachments']);
unset($item['comment_count']);
unset($item['comment_status']);
unset($item['thumbnail']);
unset($item['custom_fields']);
unset($item['thumbnail_size']);
unset($item['thumbnail_images']['full']);
unset($item['thumbnail_images']['thumbnail']);
unset($item['thumbnail_images']['post-thumbnail']);
return $item;
}));
Cache::forever('a440:wordpress:categories', collect(self::wp_get('get_category_index')['categories']));
}
示例5: 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);
}
}
示例6: getKeyInfoObjects
/**
* @param string $keyPattern
* @param int|null $limit
*
* @return array|ProvidesKeyInformation[]
*/
public function getKeyInfoObjects($keyPattern, $limit)
{
$keys = $this->redis->keys($keyPattern);
if (!is_null($limit)) {
$keys = array_slice($keys, 0, $limit);
}
return array_map([$this, 'getKeyInfoObject'], $keys);
}
示例7: 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));
}
}
示例8: postDeleteNode
public function postDeleteNode()
{
$node = \Input::get('node');
foreach (\Redis::keys('*') as $key) {
if (starts_with($key, $node)) {
\Redis::del($key);
}
}
}
示例9: __destruct
/**
* @return void
*/
public function __destruct()
{
// clean all messages sent and not parsed to skip unexpected errors
// on next run...
// Note: all keys have full name, trim keys until getting them without prefix
$prefixOffset = strlen($this->prefix);
$keys = array_map(function ($key) use($prefixOffset) {
return substr($key, $prefixOffset);
}, array_filter($this->client->keys("*"), function ($key) {
return preg_match(sprintf("/^(%s)/", preg_quote($this->prefix, "/")), $key);
}));
$this->client->delete($keys);
$this->client->close();
}
示例10: index
public function index()
{
\Redis::set('name', 'alegriaghost');
$name = \Redis::get('name');
\Redis::del('name');
\Debugbar::info($name);
\Debugbar::warning($name);
\Debugbar::error($name);
\Debugbar::addMessage($name, '$name');
var_dump($name);
\Redis::set('name1', 'alegriaghost1');
\Redis::set('name2', 'alegriaghost2');
\Redis::set('name3', 'alegriaghost3');
$list = Redis::keys('*');
$values = Redis::mget($list);
var_dump($list);
var_dump($values);
}
示例11: clean
/**
* Clean cache for a group given a mode.
*
* group mode : cleans all cache in the group
* notgroup mode : cleans all cache not in the group
*
* @param string $group The cache data group
* @param string $mode The mode for cleaning cache [group|notgroup]
*
* @return boolean
*
* @since 3.4
*/
public function clean($group, $mode = null)
{
if (static::isConnected() == false) {
return false;
}
$allKeys = static::$_redis->keys('*');
if ($allKeys === false) {
$allKeys = array();
}
$secret = $this->_hash;
foreach ($allKeys as $key) {
if (strpos($key, $secret . '-cache-' . $group . '-') === 0 && $mode == 'group') {
static::$_redis->delete($key);
}
if (strpos($key, $secret . '-cache-' . $group . '-') !== 0 && $mode != 'group') {
static::$_redis->delete($key);
}
}
return true;
}
示例12: flush
public function flush()
{
$this->_cache = [];
if ($this->_connected) {
try {
$keys = $this->_redis->keys($this->_prefix . $this->_blog_id . ':*');
foreach ($keys as $key) {
$this->_redis->del($key);
}
$keys = $this->_redis->keys($this->_prefix . '0:*');
foreach ($keys as $key) {
$this->_redis->del($key);
}
} catch (Exception $e) {
$this->_connected = false;
return false;
}
}
return true;
}
示例13: keys
public function keys($prefix)
{
return parent::keys($this->generateUniqueKey($prefix));
}
示例14: die
<?php
$redis = new \Redis();
$ok = $redis->connect('127.0.0.1');
$redis->select(9);
if (!$ok) {
die("redis connect failed");
}
$redis->select(9);
var_dump($key = $redis->keys("*")[0]);
//$redis->setTimeout($key, 1000);
var_dump($redis->ttl($key));
示例15: tearDown
protected function tearDown()
{
foreach ($this->redis->keys(REDIS_NAMESPACE . '*') as $key) {
$this->redis->delete($key);
}
}