public function getStatus() { // Check if the redis values exist try { //if (Redis::exists('webcast:isLive') == 1 && Redis::exists('webcast:viewers') == 1) { return response()->json(Redis::hgetall('webcast')); //} else { // return response()->json(array('isLive' => null, 'viewers' => null)); //} } catch (Predis\Connection\ConnectionException $e) { return response()->json(['isLive' => null, 'viewers' => null]); } }
public static function getInfo($str_id, array $fields = []) { $cache_key = self::getCacheKey($str_id); self::setCache($str_id); $compInfo = Redis::hgetall($cache_key); if (!empty($compInfo['CompanyDemographics'])) { $compInfo['CompanyDemographics'] = unserialize($compInfo['CompanyDemographics']); } if (empty($fields)) { return $compInfo; } else { $list = []; foreach ($fields as $key) { if (array_key_exists($key, $compInfo)) { $list[$key] = $compInfo[$key]; } } return $list; } }
public function load($slug, array $file = []) { if (!($post = Redis::hgetall(Key::post($slug, $this->language)))) { if (!$file) { $list = $this->loadList(); $file = array_key_exists($slug, $list) ? $list[$slug] : null; } if (!$file) { return null; } $processed = self::process((new Filesystem())->get($file['path'])); $post = array_merge($file, $processed); $post['published'] = $post['published']->format(\DateTime::ISO8601); $post['tags'] = json_encode($post['tags']); foreach ($post as $field => $value) { Redis::hsetnx(Key::post($slug, $this->language), $field, $value); } } $post['published'] = new \DateTime($post['published']); $post['tags'] = json_decode($post['tags']); return $post; }
public static function get($dma_name) { $dma_code = self::getDmaCode($dma_name); if (empty($dma_code)) { return []; } self::setDmaCache($dma_code); $cache_key = self::getDmaCacheKey($dma_code); $ad_key = Redis::srandmember($cache_key); if (empty($ad_key)) { return []; } else { self::checkCache($ad_key); return Redis::hgetall($ad_key); } }
/** * Create a SpaceXStats Live event. Set all the necessary Redis parameters, render a Reddit Thread template, * publish it, then broadcast a LiveStartedEvent to notify websocket listeners. * * @return mixed */ public function create() { // Turn on SpaceXStats Live Redis::set('live:active', true); // Set the streams available Redis::hmset('live:streams', ['spacex' => json_encode(Input::get('streams.spacex')), 'spacexClean' => json_encode(Input::get('streams.spacexClean')), 'nasa' => json_encode(Input::get('streams.nasa'))]); // Set the countdown Redis::hmset('live:countdown', ['to' => Input::get('countdown.to'), 'isPaused' => false]); // Set the details Redis::set('live:title', Input::get('title')); Redis::hmset('live:description', ['raw' => Input::get('description.raw'), 'markdown' => Parsedown::instance()->parse(Input::get('description.raw'))]); Redis::set('live:isForLaunch', Input::get('isForLaunch')); Redis::set('live:resources', json_encode(Input::get('resources'))); Redis::set('live:sections', json_encode(Input::get('sections'))); Redis::set('live:status', 'Upcoming'); // Set the Reddit parameters Redis::hmset('live:reddit', ['title' => Input::get('reddit.title')]); // Create the canned responses Redis::hmset('live:cannedResponses', ['holdAbort' => 'HOLD HOLD HOLD. The countdown has been aborted.', 'terminalCount' => 'Terminal count has now begun. From this point forward, any scrubs will result in a recycle to T-10 minutes.', 'inProgress' => 'Liftoff of ' . Mission::future()->first()->name . '!', 'maxQ' => 'MaxQ, at this point in flight, the vehicle is flying through maximum aerodynamic pressure.', 'MECO' => "MECO! The vehicle's first stage engines have shutdown in preparation for stage separation.", 'stageSep' => 'Stage separation confirmed.', 'mVacIgnition' => "Falcon's upper stage Merlin Vacuum engine has ignited for the ride to orbit.", 'SECO' => 'SECO! Falcon is now in orbit!', 'missionSuccess' => 'Success! SpaceX has completed another successful mission!', 'missionFailure' => 'We appear to have had a failure. We will bring more information to you as it is made available.']); // Render the Reddit thread template $templatedOutput = view('templates.livethreadcontents')->with(array())->render(); // Create the Reddit thread (create a service for this) $reddit = new Reddit(Config::get('services.reddit.username'), Config::get('services.reddit.password'), Config::get('services.reddit.id'), Config::get('services.reddit.secret')); $reddit->setUserAgent('/u/ElongatedMuskrat by /u/EchoLogic. Runs various /r/SpaceX-related tasks.'); // Create a post $subreddit = App::environment('production') ? 'spacex' : 'echocss'; $response = $reddit->subreddit($subreddit)->submit(['kind' => 'self', 'sendreplies' => true, 'text' => $templatedOutput, 'title' => Input::get('reddit.title')]); Redis::hmset('live:reddit', ['thing' => $response->data->name]); // Broadcast event to turn on spacexstats live event(new LiveStartedEvent(['active' => true, 'streams' => ['spacex' => Input::get('streams.spacex'), 'spacexClean' => Input::get('streams.spacexClean'), 'nasa' => Input::get('streams.nasa')], 'countdown' => ['to' => Input::get('countdown.to'), 'isPaused' => false], 'title' => Input::get('title'), 'reddit' => ['title' => Input::get('reddit.title'), 'thing' => $response->data->name], 'description' => Redis::hgetall('live:description'), 'isForLaunch' => Input::get('isForLaunch'), 'resources' => Input::get('resources'), 'sections' => Input::get('sections'), 'status' => 'Upcoming', 'cannedResponses' => Redis::hgetall('live:cannedResponses')])); // Respond return response()->json(null, 204); }
/** * {@inheritdoc} */ public function getValues() { return Redis::hgetall(self::KEY_VALUES); }
public static function getInfo($job_id, array $fields = []) { $cache_key = self::getCacheKey($job_id); self::setCache($job_id); $jobInfo = Redis::hgetall($cache_key); if (empty($fields)) { return $jobInfo; } else { $list = []; foreach ($fields as $key) { if (array_key_exists($key, $jobInfo)) { $list[$key] = $jobInfo[$key]; } } return $list; } }
protected function getFutureMission($data) { JavaScript::put(['mission' => $data['mission'], 'webcast' => Redis::hgetall('webcast')]); $data['recentTweets'] = Object::inMissionControl()->where('type', MissionControlType::Tweet)->take(10)->get(); return view('missions.futureMission', $data); }