示例#1
0
 /**
  * 获取动态出入金、转账记录
  * @return mixed 成功返回对应记录,失败返回false
  */
 private function get_my_log()
 {
     require_once './include/Predis/Autoloader.php';
     Predis\Autoloader::register();
     try {
         $r = new Predis\Client();
         $r->connect('127.0.0.1', 6379);
         $my_log_len = $r->llen($this->config->item('encryption_key'));
         return $my_log_len == 0 ? false : $r->lrange($this->config->item('encryption_key'), 0, $my_log_len - 1);
     } catch (Exception $e) {
         return false;
     }
 }
示例#2
0
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function fire()
 {
     // Connect to the Redis backend using Predis
     $redis = new \Predis\Client(array('host' => \Config::get('database.redis.default.host'), 'port' => \Config::get('database.redis.default.port')));
     // Count the amount of jobs in the queue by
     // issuing a Redis LRANGE command:
     //
     // http://redis.io/commands/LRANGE
     $redis_count = count($redis->lrange('queues:default', 0, -1));
     $this->line('Redis reports ' . $redis_count . ' jobs in the queue (queues:default)');
     // Get the Queued job count from the database
     $db_info = \SeatQueueInformation::where('status', '=', 'Queued')->count();
     $this->line('The database reports ' . $db_info . ' queued jobs');
     // If the amount of jobs in the redis queue does
     // not match that of the database, just warn
     // about this.
     if ($db_info != $redis_count) {
         $this->info('[!] The redis & db queued counts are not the same. This is not always a bad thing');
     }
     // Get the Done job count frmo the database
     $db_info = \SeatQueueInformation::where('status', '=', 'Done')->count();
     $this->line('The database reports ' . $db_info . ' done jobs');
     // Get the Error job count from the database
     $db_info = \SeatQueueInformation::where('status', '=', 'Error')->count();
     // If there are Error jobs, loop over them and
     // print the status details
     if ($db_info > 0) {
         $this->comment('Current error-state jobs (' . $db_info . '):');
         foreach (\SeatQueueInformation::where('status', '=', 'Error')->get() as $row) {
             $this->line('OwnerID: ' . $row->ownerID . ' | Scope: ' . $row->scope . ' | API: ' . $row->api . ' | Status: "' . str_limit($row->output, 20, '...') . '" | Created: ' . Carbon::parse($row->created_at)->diffForHumans() . ' | Last updated: ' . Carbon::parse($row->updated_at)->diffForHumans());
         }
     } else {
         $this->line('The database reports ' . $db_info . ' error jobs');
     }
     // Get the Working jobs from the database
     $db_info = \SeatQueueInformation::where('status', '=', 'Working')->count();
     if ($db_info > 0) {
         $this->comment('Current working-state jobs (' . $db_info . '):');
         foreach (\SeatQueueInformation::where('status', '=', 'Working')->get() as $row) {
             $this->line('OwnerID: ' . $row->ownerID . ' | Scope: ' . $row->scope . ' | API: ' . $row->api . ' | Status: "' . $row->output . '" | Created: ' . Carbon::parse($row->created_at)->diffForHumans() . ' | Last updated: ' . Carbon::parse($row->updated_at)->diffForHumans());
         }
     } else {
         $this->line('The database reports ' . $db_info . ' working jobs');
     }
 }
示例#3
0
文件: list.php 项目: cdandy/code-lib
<?php

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
/**
 * Description of list
 *
 * @author changdi
 */
require '../shared.php';
$predis = new Predis\Client($single_server);
//var_dump($predis->rpush('list-key','last'));
//var_dump($predis->lpush('list-key','first'));
//var_dump($predis->rpush('list-key','new last'));
var_dump($predis->lrange('list-key', 0, -1));
//var_dump($predis->lpop('list-key'));
//var_dump($predis->rpop('list-key'));
var_dump($predis->lrange('list-key', 0, -1));
var_dump($predis->rpush('list-key', 'a', 'b', 'c'));
var_dump($predis->lrange('list-key', 0, -1));
var_dump($predis->ltrim('list-key', 2, -1));
var_dump($predis->lrange('list-key', 0, -1));
<?php

require_once 'vendor/autoload.php';
require_once 'classes/service/DisruptionService.php';
require_once 'classes/converter/TrainServiceConverter.php';
$redisClient = new Predis\Client(getenv('DB_PORT'));
$converter = new TrainServiceConverter();
$targetStation = getenv('APP_STATION');
while (true) {
    $listId = 'dep-' . $targetStation;
    echo "ListId: " . $listId . "\n";
    $values = $redisClient->lrange($listId, 0, 5);
    //var_dump($values);
    for ($i = 0; $i < count($values); $i++) {
        $service = $converter->fromJson($values[$i]);
        echo $service . "\n";
    }
    echo "\n\n";
    sleep(10);
}
//
//
//foreach ($disruption as $disruptionDetail) {
//
//  $stoppingPoints = $disruptionDetail->stoppingPoints;
//  if (in_array($targetStation, $stoppingPoints)) {
//
//    $std = array_search($targetStation, $stoppingPoints);
//
//    $idArray = array(
//        "dis",
示例#5
0
 public function getDeleteQueuedJob($id)
 {
     if (!\Auth::isSuperUser()) {
         App::abort(404);
     }
     // Get the Redis JobID from the databse for this jib
     $redis_job_id = \SeatQueueInformation::where('id', $id)->pluck('jobID');
     // Connect to redis and loop over the queued jobs, looking for the job
     $redis = new Predis\Client(array('host' => Config::get('database.redis.default.host'), 'port' => Config::get('database.redis.default.port')));
     // Loop over the jobs in redis, looking for the one we want to delete
     foreach ($redis->lrange('queues:default', 0, -1) as $redis_job) {
         // Delete it if we match the jobID
         if (strpos($redis_job, $redis_job_id)) {
             $redis->lrem('queues:default', 0, $redis_job);
         }
     }
     // Delete if from the database too
     \SeatQueueInformation::where('status', 'Queued')->where('id', $id)->delete();
     return Response::json();
 }
示例#6
0
<?php

header('Content-Type: text/html; charset=utf-8', true);
error_reporting(E_ALL);
require "predis/autoload.php";
Predis\Autoloader::register();
$redis = new Predis\Client();
/*  If uses external server

	$client = new Predis\Client([
	    'scheme' => 'tcp',
	    'host'   => '127.0.0.1',
	    'port'   => 6379,
	]);

*/
//29392
// id объекта недвижимости. Он есть ключом для всего хэша. По запросу именно id будут выдаваться все данные объекта из базы.
$prop_id = rand(00, 99999);
echo 'GENERATED PROPERTY ID: ', $prop_id, '<br>';
// создаем хэш (объект недвижимости) с генерированным id в качестве ключа.
$redis->hmset($prop_id, array("type" => "Новобудови", "name" => "Двокімнатна квартира", "location" => "м.Чернігів, просп. Миру", "description" => "Продається двокімнатна квартира в центрі Чернігова", "sdelka" => "Продаж", "rooms" => 2, "floor" => 5, "floors_total" => 9, "area" => 32, "price" => "22000\$"));
// и запишем этот ключ в отдельную базу, где будем хранить все id всех объявлений.
$list = 'Properties';
$redis->rpush($list, $prop_id);
echo '<br>Properties in list: ', $redis->llen($list), '<br><br>';
echo '<br>There are: <pre>', print_r($redis->lrange($list, 0, -1)), '</pre><br><br>';
//echo '<br>', var_dump($res), '<br><br>';
$res1 = $redis->hgetall($prop_id);
echo var_dump($res1);
<?php

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
/**
 * Description of list_pop_movement
 *
 * @author changdi
 */
require "../shared.php";
$predis = new Predis\Client($single_server);
//var_dump($predis->rpush('list','item1'));
//var_dump($predis->rpush('list','item2'));
//var_dump($predis->rpush('list2','item3'));
//var_dump($predis->brpoplpush('list2','list',1));
//var_dump($predis->brpoplpush('list2','list',1));
var_dump($predis->brpoplpush('list', 'list2', 1));
var_dump($predis->blpop(['list', 'list2'], 1));
var_dump($predis->blpop(['list', 'list2'], 1));
var_dump($predis->blpop(['list', 'list2'], 1));
var_dump($predis->blpop(['list', 'list2'], 1));
var_dump($predis->lrange('list', 0, -1));
var_dump($predis->lrange('list2', 0, -1));