/** * * */ public function welcome() { $topic = new \App\Topic(); $topics = $topic->recentlyCreated(); $categories = new \App\Categories(); $categories = $categories->all(); //If user then check if they have confirmed email and username if (Auth::user()) { //if email is not confirm if (Auth::user()->confirmed == 0) { return redirect('/verification'); } //if displayname is not set if (empty(Auth::user()->displayname)) { return redirect()->action('ProfileController@createName'); } } $storage = Redis::connection(); $mostView = $storage->zRevRange('postViews', 0, 1); foreach ($mostView as $value) { $id = str_replace('post:', '', $value); // echo "<br> post". $id; } return view('welcome', compact('topics', 'categories')); }
public function __construct() { $this->redis = Redis::connection(); if (!$this->redis) { throw new \Exception("redis connection error", 80000); } }
private function registerCache() { $this->app->singleton(Cache::class, function ($app) { $config = $this->laravelToDoctrineConfigMapper(); $cacheClass = "\\Doctrine\\Common\\Cache\\" . $config['type']; if (!class_exists($cacheClass)) { throw new Exception\ImplementationNotFound($cacheClass); } switch ($config['type']) { case 'ArrayCache': $cache = new $cacheClass(); break; case 'FilesystemCache': $cache = new $cacheClass($config['dir']); break; case 'MemcacheCache': $cache = new $cacheClass(); $cache->setMemcache($this->setupMemcache($config)); break; case "PredisCache": $cache = new $cacheClass(Redis::connection($config['connection'])); break; } if (Config::has('d2bcache.namespace')) { $cache->setNamespace(Config::get('d2bcache.namespace')); } return $cache; }); }
public function checkRedis($config) { $startTime = $this->slog_time(); $checkResult['checkType'] = 'Check Redis'; $checkResult['checkService'] = 'Connect Redis'; $checkResult['type'] = 'Redis'; $checkResult['url'] = Config::get('database.redis.' . $config['redis'] . '.host'); try { $redis = Redis::connection(); $ping = $redis->ping(); if (empty($redis)) { $checkResult['setStatus'] = false; $checkResult['setMessage'] = 'fail'; $checkResult['setTime'] = $this->elog_time($startTime); } else { $checkResult['setStatus'] = true; $checkResult['setMessage'] = 'Success'; $checkResult['setTime'] = $this->elog_time($startTime); } } catch (\Exception $e) { $checkResult['setStatus'] = false; $checkResult['setMessage'] = $e->getMessage(); $checkResult['setTime'] = $this->elog_time($startTime); } return $checkResult; }
public function __construct($arrInfo) { $this->arr = $arrInfo; // $this->redis = new Redis(); $this->redis = Redis::connection('default'); // $this->redis->connect('127.0.0.1',6379); }
public function issue($type, UserModel $destinationUser, ProjectModel $projectModel, ActivityModel $activityModel, $corpus) { $notification = NotificationModel::generate($type, $destinationUser, $projectModel, $activityModel, $corpus); $not = $this->notificationRepository->save($notification); $redis = Redis::connection(); $transformer = \App::make(NotificationTransformer::class); $redis->publish($destinationUser->hash, json_encode($transformer->transform($notification))); return $not; }
public function setDescription() { //Redisアクセス $redisData = Redis::connection(); $setData[] = array('parking_space_id' => '1', 'description_id' => '1', 'description_type' => '3', 'title_text' => '夜はお静かに'); $setJsonData = json_encode($setData, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE); //$redisData->delete('00000001'); $redisData->hSet('parking_description_1', '1', $setJsonData); }
public function sendMessage(Request $request) { try { $redis = Redis::connection(); $redis->publish('message', $request->get('message')); return redirect('writemessage'); } catch (Exception $exc) { echo $exc->getTraceAsString(); } }
/** * Extend broadcast manager */ public function boot() { //publish $this->publishes([sprintf('%1$s%2$s..%2$s%3$s%2$s%3$s.php', __DIR__, DIRECTORY_SEPARATOR, Constants\Common::TAG_CONFIG) => base_path(sprintf('%s%s%s.php', Constants\Common::TAG_CONFIG, DIRECTORY_SEPARATOR, Constants\Common::T_NAMESPACE))], Constants\Common::TAG_CONFIG); //extend broadcast manager app(BroadcastManager::class)->extend('socket.io', function ($app) { $config = $app['config']; //init socket.io broadcaster return new SocketIOBroadcaster(new Emitter(Redis::connection($config->get('broadcasting.connections.socket\\.io.redis.connection', 'default')), $config->get(sprintf('%s.emitter.prefix', Constants\Common::T_NAMESPACE), Constants\Common::EMITTER_PREFIX))); }); }
public function authenticate(Request $request) { \R::setup('mysql:host=localhost;dbname=gazingle', 'root', ''); $redis = Redis::connection(); $user = \R::getRow('select * from users where email = "' . $request->email . '"'); //return $user; if ($request->password === \Crypt::decrypt($user['password'])) { \Auth::loginUsingId($user['id']); $redis->set(\Crypt::encrypt($request->email), $user['id']); return $redis->get($request->email); } return response('Unauthorized.', 401); }
public function show($id) { $redis = Redis::connection('default'); $article = $redis->get("article_{$id}"); if ($article) { $article = unserialize($article); } else { $article = Articles::find($id); if (!$article) { return view('errors.404'); } $article->content = EndaEditor::MarkDecode($article->content); $redis->set("article_{$id}", serialize($article)); } return view('articles.show')->with('article', $article); }
/** * 駐車場リストのKeyからRedisのValueを取得 * * @return results JSON形式 */ public function redisTest() { //$parkingSpaceIdList = array('1' => 'AAA', '2' => 'BBB', '3' => 'CCC'); $parkingSpaceIdList = $_GET['ids']; $redis = Redis::connection(); $results = ''; //$redis->mget($parkingSpaceIdList)->; // $distance = ''; foreach ($parkingSpaceIdList as $parkingSpaceId) { $results = $results . $redis->get($parkingSpaceId); // $results[] = $redis->get($parkingSpaceId)."distance"; } // $data =json_encode($results); return $results; // return $parkingSpaceIdList; // return $_GET['id']; }
public function LocusGet(Request $request) { $uid = $request->input('uid'); if (!is_numeric($uid)) { $this->throwERROR(501, '参数错误'); } $uniKey = md5(date('Y-m-d', time()) . $uid); $redis = Redis::connection(); $locusData = $redis->get($uniKey); if ($locusData == '') { $this->throwERROR(400, '暂无该用户数据'); } $locusArray = json_decode($locusData, true); $locusNow = $locusArray[count($locusArray) - 1]; $lat = ''; $lon = ''; foreach ($locusNow as $locus) { $lat = $locus['lat']; $lon = $locus['lon']; } echo json_encode(array('status' => 200, 'msg' => 'ok', 'data' => array('lat' => $lat, 'lon' => $lon))); }
public function register() { $this->app->singleton('DbRedis', function ($app) { return Redis::connection(); }); }
public function __construct(BuyerService $buyerService, SellerService $sellerService) { $this->redis = Redis::connection(); $this->buyerService = $buyerService; $this->sellerService = $sellerService; }
public function __construct() { $this->storage = Storage::connection(); }
/** * 未登录时,获取内存中的购物车信息 * */ public function cacheList() { $redis = Redis::connection(); // $redis->flushAll(); // $redis_sort_option=array('BY'=>'ftime_*', // 'SORT'=>'DESC', // 'GET'=>array('#','pid_*','ftime_*') // ); // dd($redis->sort('favorite_*',$redis_sort_option)); $list = $redis->hGetAll('favorite'); dd($list); // // $data['favorites'] = array(); // // // // if (view()->exists('favorite.cachelist')) // return view('favorite.cachelist')->with('msg',$this->msg); // else // return redirect('home'); }
public function __construct() { $this->redis = Redis::connection(); $this->wxClient = new WeixinClient(); $this->deviceClient = new DeviceClient(); }
/** * Checks the system meets all the requirements needed to run Deployer. * * @return bool */ protected function checkRequirements() { $errors = false; // Check PHP version: if (!version_compare(PHP_VERSION, '5.5.9', '>=')) { $this->error('PHP 5.5.9 or higher is required'); $errors = true; } // Check for required PHP extensions $required_extensions = ['PDO', 'curl', 'gd', 'json', 'tokenizer', 'openssl', 'mbstring']; foreach ($required_extensions as $extension) { if (!extension_loaded($extension)) { $this->error('Extension required: ' . $extension); $errors = true; } } if (!count($this->getDatabaseDrivers())) { $this->error('At least 1 PDO driver is required. Either sqlite, mysql, pgsql or sqlsrv, check your php.ini file'); $errors = true; } // Functions needed by symfony process $required_functions = ['proc_open']; foreach ($required_functions as $function) { if (!function_exists($function)) { $this->error('Function required: ' . $function . '. Is it disabled in php.ini?'); $errors = true; } } // Programs needed in $PATH $required_commands = ['ssh', 'ssh-keygen', 'git', 'scp', 'tar', 'gzip', 'rsync', 'bash']; foreach ($required_commands as $command) { $process = new Process('which ' . $command); $process->setTimeout(null); $process->run(); if (!$process->isSuccessful()) { $this->error('Program not found in path: ' . $command); $errors = true; } } $required_one = ['node', 'nodejs']; $found = false; foreach ($required_one as $command) { $process = new Process('which ' . $command); $process->setTimeout(null); $process->run(); if ($process->isSuccessful()) { $found = true; break; } } if (!$found) { $this->error('node.js was not found'); $errors = true; } // Files and directories which need to be writable $writable = ['.env', 'storage', 'storage/logs', 'storage/app', 'storage/app/mirrors', 'storage/app/tmp', 'storage/framework', 'storage/framework/cache', 'storage/framework/sessions', 'storage/framework/views', 'bootstrap/cache', 'public/upload']; foreach ($writable as $path) { if (!is_writeable(base_path($path))) { $this->error($path . ' is not writeable'); $errors = true; } } // Check that redis is running try { Redis::connection()->ping(); } catch (\Exception $e) { $this->error('Redis is not running'); $errors = true; } if (config('queue.default') === 'beanstalkd') { $connected = Queue::connection()->getPheanstalk()->getConnection()->isServiceListening(); if (!$connected) { $this->error('Beanstalkd is not running'); $errors = true; } } if ($errors) { $this->line(''); $this->block('Deployer cannot be installed. Please review the errors above before continuing.'); $this->line(''); return false; } return true; }
public function getSuitTicketFromRedis($key) { try { $redis = Redis::connection(); } catch (\Exception $e) { \Log::info(sprintf("set ticket into redis error,")); } return $redis->get($key); }
/** * Decorate a Flysystem adapter with a metadata cache. * * @param \League\Flysystem\AdapterInterface $adapter * @param array $config * @return \League\Flysystem\AdapterInterface */ protected function decorateWithCachedAdapter(AdapterInterface $adapter, array $config) { if (($cacheDriver = Arr::get($config, 'driver', false)) !== false && (is_a($cacheDriver, 'League\\Flysystem\\Cached\\CacheInterface') || class_exists($driverName = Arr::get($this->cacheDrivers, $cacheDriver, $cacheDriver)))) { if (isset($driverName)) { switch ($driverName) { case 'League\\Flysystem\\Cached\\Storage\\Adapter': $cacheDriver = new \League\Flysystem\Cached\Storage\Adapter($this->disk(Arr::get($config, 'disk', 'local'))->getAdapter(), Arr::get($config, 'file', 'flysystem.cache'), Arr::get($config, 'expire', null)); break; case 'Madewithlove\\IlluminatePsrCacheBridge\\Laravel\\CacheItemPool': $cacheDriver = new \League\Flysystem\Cached\Storage\Psr6Cache(new \Madewithlove\IlluminatePsrCacheBridge\Laravel\CacheItemPool($this->app->make(\Illuminate\Contracts\Cache\Repository::class)), Arr::get($config, 'key', 'flysystem'), Arr::get($config, 'expire', null)); break; case 'League\\Flysystem\\Cached\\Storage\\Memcached': if (class_exists('Memcached')) { $memcached = new \Memcached(); $memcached->addServer(Arr::get($config, 'host', 'localhost'), Arr::get($config, 'port', 11211)); $cacheDriver = new \League\Flysystem\Cached\Storage\Memcached($memcached, Arr::get($config, 'key', 'flysystem'), Arr::get($config, 'expire', null)); } else { return $adapter; } break; case 'League\\Flysystem\\Cached\\Storage\\Memory': $cacheDriver = new \League\Flysystem\Cached\Storage\Memory(); break; case 'League\\Flysystem\\Cached\\Storage\\Noop': $cacheDriver = new \League\Flysystem\Cached\Storage\Noop(); break; case 'League\\Flysystem\\Cached\\Storage\\PhpRedis': case 'League\\Flysystem\\Cached\\Storage\\Predis': $cacheDriver = new \League\Flysystem\Cached\Storage\Predis(\Illuminate\Support\Facades\Redis::connection(Arr::get($config, 'connection', 'default')), Arr::get($config, 'key', 'flysystem'), Arr::get($config, 'expire', null)); break; case 'League\\Flysystem\\Cached\\Storage\\Stash': if (class_exists('Stash\\Pool')) { if (($backend = Arr::get($config, 'backend', false)) !== false && (is_a($backend, 'Stash\\Interfaces\\DriverInterface') || class_exists($backend))) { if (is_a($backend, 'Stash\\Interfaces\\DriverInterface')) { $backendInstance = $backend; } else { $backendInstance = new $backend(); $backendInstance->setOptions(Arr::get($config, 'options', [])); } $pool = new \Stash\Pool($backendInstance); } else { $pool = new \Stash\Pool(); } $cacheDriver = new \League\Flysystem\Cached\Storage\Stash($pool, Arr::get($config, 'key', 'flysystem'), Arr::get($config, 'expire', null)); } else { return $adapter; } break; default: return $adapter; } } return new \League\Flysystem\Cached\CachedAdapter($adapter, $cacheDriver); } else { return $adapter; } }
public function __construct() { parent::__construct(); $this->_conn = Redis::connection(); }
<?php /* **Author:tianling **createTime:15/11/21 下午6:18 */ use Illuminate\Database\Eloquent\Model; use Illuminate\Support\Facades\Redis; $uniKey = '2cb6418b1e6182093385c8150891c46e'; $redis = Redis::connection(); $locusData = $redis->get($uniKey); echo $locusData;
public function connectRedis() { $redis = Redis::connection(); return $redis; }
private function recAudio() { $user_id=Input::get('toUser'); $fromUserNick=Input::get('fromUserNick'); $fromUser=Input::get('fromUser'); $msg_id=Input::get('msgId'); $url=Input::get('url'); $toUserTokenId=$this->getRongTokenIdByUserId($user_id); if ($toUserTokenId) { $content=$this->createAudioContent($fromUser,$fromUserNick,$msg_id,$url); // $RE=RongYun::messagePublish($fromUserNick,array($toUserTokenId),'RC:TxtMsg',$content); // Log::info("RongYun::messagePublish($fromUserNick,array($toUserTokenId),'RC:TxtMsg',$content); ".$RE); $arr=['type'=>'xsk','msgId'=>$msg_id,'fNick'=>$fromUserNick,'fromUser'=>$fromUser,'toUser'=>$user_id]; $redis=Redis::connection('default'); // Redis:set($arr['type'].$arr['msgId'],1); $redis->SETEX($arr['type'].$arr['msgId'],120,1); // Log::info('Redis:set'.$arr['type'].$arr['msgId']); // Log::info('Redis:get'.Redis::get($arr['type'].$arr['msgId'])); $job=(new SendUnreadPush($arr))->delay(60); $this->dispatch($job); } }
public function __construct(Request $request) { $this->redis = Redis::connection(); parent::__construct($request); }
public function handle($data) { $redis = Redis::connection(); $redis->publish(self::CHANNEL, $data); }
/** * Display the specified resource. * * @param char $slug */ public function show($displayname, $slug) { $categories = new \App\Categories(); $categories = $categories->all(); DB::connection()->enableQueryLog(); $topic = new Topic(); $topic = $topic->getTopic($slug); /** * Performance and redis check */ /* $log = DB::getQueryLog(); print_r($log);*/ if (empty($topic)) { return "not found" . $topic; } else { $data = TopicImages::where('topic_uuid', $topic->topic_uuid)->first(); //Increment page view and keep track of what popular in redis $storage = Redis::connection(); if ($storage->zScore('postViews', 'post:' . $topic->topic_uuid)) { $storage->pipeline(function ($pipe) use($topic) { $pipe->zIncrBy('postViews', 1, 'post:' . $topic->topic_uuid); $pipe->incr('post:' . $topic->topic_uuid . ":views"); }); } else { $views = $storage->incr('post:' . $topic->topic_uuid . ":views"); $storage->zIncrBy('postViews', 1, 'post:' . $topic->topic_uuid); } //Get post views from redis $views = $storage->get('post:' . $topic->topic_uuid . ":views"); $is_user = null; $dt = Carbon::parse($topic->topic_created_at); $topic_id = $topic->id; $title = $topic->topic; $topic_type = $topic->topic_type; $body = $topic->body; $is_edited = $topic->is_edited; $username = $topic->displayname; $user_fname = $topic->firstname; $cate_name = $topic->cate_name; $slug = $topic->topic_slug; $uuid = $topic->topic_uuid; $topics_uid = $topic->topics_uid; $user_descs = $topic->description; $poster_img = $topic->profile_img; $topic_created_at = $topic->topic_created_at; $topic_updated_at = $topic->topic_updated_at; $topic_location = $topic->location_id; if (!empty($topic->tags)) { $tags = explode(',', $topic->tags); } else { $tags = null; } $created_at = $dt->diffForHumans(); SEOMeta::setTitle($title); SEOMeta::setDescription(str_limit($body, 152)); $req = new Request(); $url = $req->url(); OpenGraph::setTitle($title); OpenGraph::setDescription($body); OpenGraph::setUrl($url); OpenGraph::addImage($data['filename']); OpenGraph::addProperty('type', 'articles'); OpenGraph::addProperty('locale:alternate', ['th-th', 'en-us']); /*$topic = new Topic(); $topic_replies = $topic->getReplies($uuid);*/ //Check if this is the owner if (!empty(Auth::user()->uuid)) { if (Auth::user()->uuid == $topics_uid) { $is_user = '******'; } } return view('pages.topic.topic', compact('topic_id', 'title', 'body', 'topic_type', 'username', 'slug', 'uuid', 'is_user', 'is_edited', 'topics_uid', 'user_descs', 'tags', 'poster_img', 'user_fname', 'cate_name', 'topic_updated_at', 'topic_created_at', 'views', 'topic_location', 'categories')); } }
public function getParkingSetting() { //Redisアクセス $redisData = Redis::connection(); $key_Id = "parking_setting_" . $_GET['parkingId']; $redisList = $redisData->get($key_Id); $getRedisList = json_decode($redisList, true, JSON_UNESCAPED_UNICODE); $getDataList[] = array('accept_period' => $getRedisList[0]['accept_period']); $getDataList = array('results' => $getDataList); //var_dump($getRedisList[0]['parking_space_id']); return json_encode($getDataList, JSON_UNESCAPED_UNICODE); //return $getRedisList; }