当前位置: 首页>>代码示例>>PHP>>正文


PHP Redis::lpush方法代码示例

本文整理汇总了PHP中Redis::lpush方法的典型用法代码示例。如果您正苦于以下问题:PHP Redis::lpush方法的具体用法?PHP Redis::lpush怎么用?PHP Redis::lpush使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Redis的用法示例。


在下文中一共展示了Redis::lpush方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: prepend

 /**
  * @param mixed $value
  *
  * @return RedisNoSQLList
  */
 public function prepend($value)
 {
     $this->redis->lpush($this->key, $value);
     if ($this->timeout) {
         $this->redis->setTimeout($this->key, $this->timeout);
     }
     return $this;
 }
开发者ID:justthefish,项目名称:hesper,代码行数:13,代码来源:RedisNoSQLList.php

示例2: testObject

 public function testObject()
 {
     $this->redis->del('key');
     $this->assertTrue($this->redis->object('encoding', 'key') === FALSE);
     $this->assertTrue($this->redis->object('refcount', 'key') === FALSE);
     $this->assertTrue($this->redis->object('idletime', 'key') === FALSE);
     $this->redis->set('key', 'value');
     $this->assertTrue($this->redis->object('encoding', 'key') === "raw");
     $this->assertTrue($this->redis->object('refcount', 'key') === 1);
     $this->assertTrue($this->redis->object('idletime', 'key') === 0);
     $this->redis->del('key');
     $this->redis->lpush('key', 'value');
     $this->assertTrue($this->redis->object('encoding', 'key') === "ziplist");
     $this->assertTrue($this->redis->object('refcount', 'key') === 1);
     $this->assertTrue($this->redis->object('idletime', 'key') === 0);
     $this->redis->del('key');
     $this->redis->sadd('key', 'value');
     $this->assertTrue($this->redis->object('encoding', 'key') === "hashtable");
     $this->assertTrue($this->redis->object('refcount', 'key') === 1);
     $this->assertTrue($this->redis->object('idletime', 'key') === 0);
     $this->redis->del('key');
     $this->redis->sadd('key', 42);
     $this->redis->sadd('key', 1729);
     $this->assertTrue($this->redis->object('encoding', 'key') === "intset");
     $this->assertTrue($this->redis->object('refcount', 'key') === 1);
     $this->assertTrue($this->redis->object('idletime', 'key') === 0);
     $this->redis->del('key');
     $this->redis->lpush('key', str_repeat('A', pow(10, 6)));
     // 1M elements, too big for a ziplist.
     $this->assertTrue($this->redis->object('encoding', 'key') === "linkedlist");
     $this->assertTrue($this->redis->object('refcount', 'key') === 1);
     $this->assertTrue($this->redis->object('idletime', 'key') === 0);
 }
开发者ID:stonegithubs,项目名称:phpredis,代码行数:33,代码来源:TestRedis.php

示例3: update_weixin_user

 public function update_weixin_user($openid, $broker_id)
 {
     $this->api_model->update_weixin_user($openid);
     $redis = new Redis();
     $redis->connect(REDIS_HOST, REDIS_PORT);
     $redis->auth(REDIS_AUTH);
     $key = "map:" . $broker_id;
     $users = $redis->lrange($key, 0, -1);
     if (!in_array($openid, $users)) {
         $redis->lpush($key, $openid);
     }
 }
开发者ID:binshen,项目名称:website,代码行数:12,代码来源:api.php

示例4: Redis

 function my_onStart($serv)
 {
     $redis = new Redis();
     $redis->pconnect('127.0.0.1', 6379);
     $redis->flushAll();
     $work_arr = array();
     for ($i = 0; $i < $serv->setting['task_worker_num']; $i++) {
         $redis->lpush('free', $i);
         $work_arr[] = $i;
     }
     echo "MasterPid={$serv->master_pid}|Manager_pid={$serv->manager_pid}\n";
     echo "Server: start.Swoole version is [" . SWOOLE_VERSION . "]\n";
 }
开发者ID:hytzxd,项目名称:swoole-doc,代码行数:13,代码来源:ServerCommand.php

示例5: state

 /**
  * Change state
  *
  * @param $state
  * @return $this
  */
 public function state($state)
 {
     $this->emit($state);
     $this->removeState();
     // Keep "FIFO!"
     $score = $this->injectors['timing'] + $this->injectors['priority'];
     $this->set('state', $state);
     $this->client->zadd('q:jobs', $score, $this->injectors['id']);
     $this->client->zadd('q:jobs:' . $state, $score, $this->injectors['id']);
     $this->client->zadd('q:jobs:' . $this->injectors['type'] . ':' . $state, $score, $this->injectors['id']);
     // Set inactive job to waiting list
     if ($this->queue->originalMode() && 'inactive' == $state) {
         $this->client->lpush('q:' . $this->injectors['type'] . ':jobs', 1);
     }
     $this->set('updated_at', Util::now());
     return $this;
 }
开发者ID:coderofsalvation,项目名称:php-kue,代码行数:23,代码来源:Job.php

示例6: bind

 public function bind()
 {
     $redis = new Redis();
     $redis->connect(REDIS_HOST, REDIS_PORT);
     $redis->auth(REDIS_AUTH);
     $results = $this->job_model->getWxUserKeys();
     $keys = array_map(function ($v) {
         return 'map:' . $v['broker_id'];
     }, $results);
     $redis->delete($keys);
     $results = $this->job_model->getWxUser();
     foreach ($results as $u) {
         $key = 'map:' . $u['broker_id'];
         $open_id = $u['open_id'];
         $redis->lpush($key, $open_id);
     }
 }
开发者ID:binshen,项目名称:website,代码行数:17,代码来源:job.php

示例7: testObject

 public function testObject()
 {
     /* Version 3.0.0 (represented as >= 2.9.0 in redis info)  and moving
      * forward uses "embstr" instead of "raw" for small string values */
     if (version_compare($this->version, "2.9.0", "lt")) {
         $str_small_encoding = "raw";
     } else {
         $str_small_encoding = "embstr";
     }
     $this->redis->del('key');
     $this->assertTrue($this->redis->object('encoding', 'key') === FALSE);
     $this->assertTrue($this->redis->object('refcount', 'key') === FALSE);
     $this->assertTrue($this->redis->object('idletime', 'key') === FALSE);
     $this->redis->set('key', 'value');
     $this->assertTrue($this->redis->object('encoding', 'key') === $str_small_encoding);
     $this->assertTrue($this->redis->object('refcount', 'key') === 1);
     $this->assertTrue($this->redis->object('idletime', 'key') === 0);
     $this->redis->del('key');
     $this->redis->lpush('key', 'value');
     /* Newer versions of redis are going to encode lists as 'quicklists',
      * so 'quicklist' or 'ziplist' is valid here */
     $str_encoding = $this->redis->object('encoding', 'key');
     $this->assertTrue($str_encoding === "ziplist" || $str_encoding === 'quicklist');
     $this->assertTrue($this->redis->object('refcount', 'key') === 1);
     $this->assertTrue($this->redis->object('idletime', 'key') === 0);
     $this->redis->del('key');
     $this->redis->sadd('key', 'value');
     $this->assertTrue($this->redis->object('encoding', 'key') === "hashtable");
     $this->assertTrue($this->redis->object('refcount', 'key') === 1);
     $this->assertTrue($this->redis->object('idletime', 'key') === 0);
     $this->redis->del('key');
     $this->redis->sadd('key', 42);
     $this->redis->sadd('key', 1729);
     $this->assertTrue($this->redis->object('encoding', 'key') === "intset");
     $this->assertTrue($this->redis->object('refcount', 'key') === 1);
     $this->assertTrue($this->redis->object('idletime', 'key') === 0);
     $this->redis->del('key');
     $this->redis->lpush('key', str_repeat('A', pow(10, 6)));
     // 1M elements, too big for a ziplist.
     $str_encoding = $this->redis->object('encoding', 'key');
     $this->assertTrue($str_encoding === "linkedlist" || $str_encoding == "quicklist");
     $this->assertTrue($this->redis->object('refcount', 'key') === 1);
     $this->assertTrue($this->redis->object('idletime', 'key') === 0);
 }
开发者ID:Jerry-Shaw,项目名称:phpredis,代码行数:44,代码来源:RedisTest.php

示例8: testRpopLpush

 public function testRpopLpush()
 {
     // standard case.
     $this->redis->delete('x', 'y');
     $this->redis->lpush('x', 'abc');
     $this->redis->lpush('x', 'def');
     // x = [def, abc]
     $this->redis->lpush('y', '123');
     $this->redis->lpush('y', '456');
     // y = [456, 123]
     $this->assertEquals($this->redis->rpoplpush('x', 'y'), 'abc');
     // we RPOP x, yielding abc.
     $this->assertEquals($this->redis->lgetRange('x', 0, -1), array('def'));
     // only def remains in x.
     $this->assertEquals($this->redis->lgetRange('y', 0, -1), array('abc', '456', '123'));
     // abc has been lpushed to y.
     // with an empty source, expecting no change.
     $this->redis->delete('x', 'y');
     $this->assertTrue(FALSE === $this->redis->rpoplpush('x', 'y'));
     $this->assertTrue(array() === $this->redis->lgetRange('x', 0, -1));
     $this->assertTrue(array() === $this->redis->lgetRange('y', 0, -1));
 }
开发者ID:virtulis,项目名称:phpredis,代码行数:22,代码来源:TestRedis.php

示例9: redisProducerAction

 public function redisProducerAction()
 {
     $content = $this->getpost('content');
     $config = Yaf_Application::app()->getConfig();
     $queue = 'test_queue';
     $host = $config['redis_host'];
     $port = $config['redis_port'];
     $redis = new Redis();
     $redis->connect($host, $port);
     $redis->lpush($queue, $content);
     echo 1;
     die;
 }
开发者ID:xujunjiepk,项目名称:YOF,代码行数:13,代码来源:Profile.php

示例10: Redis

try {
    $serv = new swoole_websocket_server("127.0.0.1", 9503);
    $redis = new Redis();
    $redis->connect('127.0.0.1', 6379);
    $serv->on('Open', function ($server, $req) {
        echo "connection open: " . $req->fd . "\n";
    });
    $serv->on('Message', function ($server, $frame) use($redis, $serv) {
        $request = json_decode($frame->data, true);
        print_r($request);
        $cmd = $request['cmd'];
        $data = $request['data'];
        switch ($cmd) {
            case 'login':
                $uid = 'uid_' . $frame->fd;
                $redis->lpush('uid_list', $frame->fd);
                $username = $data['username'];
                $redis->set($uid, $username);
                $user_list = get_online_users($redis);
                $response = ['cmd' => 'login', 'data' => ['user' => $username, 'user_list' => $user_list]];
                $response_data = json_encode($response);
                //通知新用户登录
                foreach ($serv->connections as $fd) {
                    $serv->push($fd, $response_data);
                }
                break;
            case 'send_msg':
                $username = $data['from'];
                $send_to = $data['send_to'];
                $content = $data['content'];
                $color = $data['color'] ?? '';
开发者ID:airzhe,项目名称:BAT-websocket-chat,代码行数:31,代码来源:websocket.php

示例11: lpush

 public function lpush($key, $value)
 {
     return parent::lpush($this->generateUniqueKey($key), $value);
 }
开发者ID:nbaiwan,项目名称:yav,代码行数:4,代码来源:CRedis.php

示例12: curl

if ($rpassword) {
    $redis_handle->auth($rpassword);
}
$redis_handle->select($rdb);
$redis_bi_key = 'bi';
while (true) {
    if ($to_exit) {
        echo "[" . date('Y-m-d H:i:s') . "] track log quit for user end\n";
        break;
    }
    if ($redis_handle->llen($redis_bi_key) > 0) {
        $url = $redis_handle->rpop($redis_bi_key);
        if (!empty($url)) {
            $result = curl($url);
            if ($result === false) {
                $redis_handle->lpush($redis_bi_key, $url);
            }
        }
    }
    //usleep(100000);
    usleep(1);
}
/**
 *
 * @param string $url
 * @param array $post_data
 * @param string $proxy
 * @param int $max_loop
 * @return mixed
 */
function curl($url, $post_data = '', $proxy = '', $max_loop = 1)
开发者ID:cfhb,项目名称:script,代码行数:31,代码来源:track_log.php

示例13: Redis

<?php

header("Content-type:text/html;charset=utf-8");
$username = $_POST['username'];
$phone = $_POST['phone'];
$redis = new Redis();
$redis->connect('127.0.0.1', 6379);
$begin_time = time();
for ($i = 0; $i < 5000; $i++) {
    $redis->set('username' . $i, $username);
    $redis->set('phone' . $i, $phone);
    $redis->lpush("tutorial-list", "Redis" . $i);
}
$arList = $redis->lrange("tutorial-list", 0, 1000);
echo "Stored string in redis:: ";
print_r($arList);
$end_time = time();
echo $end_time - $begin_time;
开发者ID:iamzcr,项目名称:iamzcr-code,代码行数:18,代码来源:redis_set.php

示例14: Redis

<?php

$redis = new Redis();
$redis->connect("127.0.0.1", "6379");
// string
$redis->delete("KeyTime");
$redis->mset(array('key111' => "key111", "key222" => "key222"));
echo (int) $redis->exists("key111");
$array = $redis->getMultiple(array("key111", "key222"));
echo "<br>";
print_r($array);
for ($i = 0; $i < 10; $i++) {
    $redis->lpush("list", $i);
}
$redis->lpop("list");
$redis->rpop("list");
echo $redis->lsize("list");
echo $redis->lget("list", 0);
echo $redis->lset("list", 1, "new_value");
$data = $redis->lRange("list", 0, -1);
echo "<pre>";
print_r($data);
$bool = $redis->ltrim("list", 0, 5);
echo $redis->lrem("list", "5");
$bool = $redis->rpoplpush("srcKey", "dstKey");
// SET
for ($i = 0; $i < 10; $i++) {
    $redis->sadd("myset", $i + rand(10, 99));
}
$bool = $redis->srem("myset", 16);
echo (int) $bool;
开发者ID:isS,项目名称:NoSQL,代码行数:31,代码来源:redisWithPHP.php

示例15: Redis

<?php

$redis = new Redis();
$redis->connect('127.0.0.1', 6379);
$channel = $argv[1];
// channel
$msg = $argv[2];
// msg
$redis->select(2);
$redis->lpush('channel' . $channel, $msg);
开发者ID:whenjonny,项目名称:queue-demo,代码行数:10,代码来源:lpush.php


注:本文中的Redis::lpush方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。