本文整理汇总了PHP中Cache::put方法的典型用法代码示例。如果您正苦于以下问题:PHP Cache::put方法的具体用法?PHP Cache::put怎么用?PHP Cache::put使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Cache
的用法示例。
在下文中一共展示了Cache::put方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: process
public static function process()
{
$security = new Security();
$security->verifyPre();
$data = stream_get_contents(fopen('php://input', 'r'));
$compressedSize = strlen($data);
$security->verifyCompressedData($data, $compressedSize);
$data = @gzdecode($data);
$uncompressedSize = strlen($data);
$security->validateData($data, $uncompressedSize);
$json = json_decode($data, true);
$security->validateJson($json);
if (isset($json['icon'])) {
$img = self::getServerIcon($json['icon']);
$json['icon'] = $img;
$data = json_encode($json);
$uncompressedSize = strlen($data);
}
$key = Util::uuid(false);
$cacheFile = Cache::getFile($key);
Log::info("Uploaded {$uncompressedSize} bytes as {$key} to {$cacheFile}");
Cache::put($key, $data);
header("Location: " . BASE_URL_VIEW . "/?id={$key}");
self::error("Compressed Size: {$compressedSize}\nUncompressed Size: {$uncompressedSize}\nRaw Upload: " . BASE_URL_VIEW . "/?id={$key}&raw=1");
}
示例2: showAll
public function showAll()
{
$key = cacheKey('Beneficiaries', 'showAll');
if (Cache::has($key)) {
$data = Cache::get($key);
} else {
$data = array();
$beneficiaries = Auth::user()->beneficiaries()->orderBy('id', 'ASC')->get();
// to get the avg per month we first need the number of months
foreach ($beneficiaries as $ben) {
$name = Crypt::decrypt($ben->name);
$bene = array('id' => intval($ben->id), 'name' => $name);
$now = new Carbon('now');
$thisMonth = $ben->transactions()->where(DB::Raw('DATE_FORMAT(`date`,"%m-%Y")'), '=', $now->format('m-Y'))->sum('amount');
$bene['month'] = floatval($thisMonth);
$data[] = $bene;
}
unset($name);
$name = array();
// order by alfabet
// Obtain a list of columns
foreach ($data as $key => $row) {
$id[$key] = $row['id'];
$name[$key] = $row['name'];
}
array_multisort($name, SORT_ASC, $id, SORT_DESC, $data);
Cache::put($key, $data, 1440);
}
return View::make('beneficiaries.all')->with('beneficiaries', $data);
}
示例3: fire
/**
* Execute the console command.
*
* @return mixed
*/
public function fire()
{
$size = DB::table('path_records')->sum('size');
Cache::put('statTotalSize', $size, 60);
$formatted = DisplaySize::format($size, 2);
$this->info($formatted);
}
示例4: store
public function store($cacheable)
{
if (is_null($this->cache_minutes)) {
return $this->storeForever($cacheable);
}
\Cache::put($this->cache_key, $cacheable, $this->cache_minutes);
}
示例5: cache
/**
* Caches a model
*
* @param string $model The name of the model
* @param string $keyPart The key to use to cache the model (e.g. primary key)
* @param \App\LaravelRestCms\BaseModel $data The model instance
* @return string
*/
public static function cache($model, $keyPart, $data)
{
$key = static::getCacheKey($model, $keyPart);
\Cache::forget($key);
\Cache::put($key, $data, static::$cacheTime);
return $model;
}
示例6: getVersions
public static function getVersions()
{
$response = array();
if (UrlUtils::checkRemoteFile('http://www.technicpack.net/api/minecraft', 15)['success']) {
$response = UrlUtils::get_url_contents('http://www.technicpack.net/api/minecraft', 15);
if ($response['success']) {
$response = json_decode($response['data'], true);
krsort($response);
Cache::put('minecraftversions', $response, 180);
return $response;
}
}
if (UrlUtils::checkRemoteFile('https://s3.amazonaws.com/Minecraft.Download/versions/versions.json', 15)['success']) {
$response = UrlUtils::get_url_contents('https://s3.amazonaws.com/Minecraft.Download/versions/versions.json', 15);
if ($response['success']) {
$mojangResponse = json_decode($response['data'], true);
$versions = array();
foreach ($mojangResponse['versions'] as $versionEntry) {
if ($versionEntry['type'] != 'release') {
continue;
}
$mcVersion = $versionEntry['id'];
$versions[$mcVersion] = array('version' => $mcVersion);
}
krsort($versions);
Cache::put('minecraftversions', $versions, 180);
return $versions;
}
}
return $response;
}
示例7: fire
/**
* Execute the console command.
*
* @return mixed
*/
public function fire()
{
if (!$this->argument('number')) {
return $this->error('No number specified.');
}
Cache::put('whatsAppAction_' . $this->argument('number'), 'stop', 5);
}
示例8: handleGet
/**
* Asks the module to handle a GET (Read) request
*
* @param $view
* @param $args
* @return Response
*/
protected function handleGet($view, $args)
{
$artist = $view;
if (!isset($artist)) {
return new Response(array('message' => "The Hive Radio music artist cover API version {$this->VERSION}", 'usage' => "cover/[artist]"), 200);
} else {
if (\Cache::has("artist_cover_{$artist}")) {
return $this->buildImageResponse(\Cache::get("artist_cover_{$artist}"));
} else {
$youtube_response = file_get_contents("https://www.googleapis.com/youtube/v3/search?q={$artist}&key=" . \Config::get('icebreath.covers.youtube_api_key') . "&fields=items(id(kind,channelId),snippet(thumbnails(medium)))&part=snippet,id");
$youtube_json = json_decode($youtube_response, true);
$items = $youtube_json['items'];
$youtube_source = null;
for ($i = 0; $i < sizeof($items); $i++) {
if ((string) $items[$i]["id"]["kind"] != "youtube#channel") {
continue;
} else {
$youtube_source = $items[$i]["snippet"]["thumbnails"]["medium"]["url"];
break;
}
}
if (isset($youtube_source) && !empty($youtube_source)) {
$data = file_get_contents($youtube_source);
$expiresAt = Carbon::now()->addHours(\Config::get('icebreath.covers.cache_time'));
\Cache::put("artist_cover_{$artist}", $data, $expiresAt);
return $this->buildImageResponse($data);
}
return $this->buildImageResponse(\File::get(base_path() . '/' . \Config::get('icebreath.covers.not_found_img')));
}
}
}
示例9: get_arrays
/**
* get static data from cache or from remote
*/
private function get_arrays()
{
if (Cache::has('stops')) {
$sn = Cache::get('stops');
extract($sn);
} else {
// vars
$base_url = 'http://api.hannesv.be/';
$endpoint = 'nmbs/stations.json';
$cache_time = 120;
// minutes
// get stop names
$client = new Client($base_url);
$result = $client->get($endpoint)->send()->json();
// start empty
$stop_names = array();
$inverted = array();
// loop
foreach ($result['stations'] as $station) {
$stop_names[(int) $station['sid']] = $station['stop'];
$inverted[$station['stop']] = (int) $station['sid'];
}
// cache result
Cache::put('stops', compact('stop_names', 'inverted'), $cache_time);
}
// return
return array($stop_names, $inverted);
}
示例10: put
/**
* Cache route
*
* @param Route $route
* @param Request $request
* @param Response $response
*/
public function put(Route $route, Request $request, Response $response)
{
$key = $this->makeCacheKey($request->url());
if (!Cache::has($key)) {
Cache::put($key, $response->getContent(), 60);
}
}
示例11: get_mails
public function get_mails(Request $request)
{
$mbox = imap_open("{email.mindfiresolutions.com:143}INBOX", "saema.miftah@mindfiresolutions.com", "1mfmail2016#") or die("can't connect: " . imap_last_error());
$MC = imap_check($mbox);
$count = 0;
$count_total = $MC->Nmsgs;
$last_page = $count_total % 10;
$this->number_of_pages = ($count_total - $last_page) / 10;
$this->result = imap_fetch_overview($mbox, "1:{$MC->Nmsgs}", 0);
$i = 0;
foreach ($this->result as $overview) {
$message = imap_fetchbody($mbox, $overview->msgno, 1.1);
$this->msg[$i] = $message;
$i++;
\Cache::put($overview->msgno, $overview->subject, 5);
}
krsort($this->result);
/*This sorting does not help.Please use only rsort.*/
$str[0] = 'success';
$result_json = array();
$result_json['val'] = $this->result;
$result_json['num'] = $this->number_of_pages;
$result_json['total'] = $count_total;
return response()->json($result_json);
}
示例12: setup
public static function setup($client_id, $client_secret, $podio_username, $podio_password, $options = array('session_manager' => null, 'curl_options' => array()))
{
// Setup client info
self::$client_id = $client_id;
self::$client_secret = $client_secret;
// Setup curl
self::$url = empty($options['api_url']) ? 'https://api.podio.com:443' : $options['api_url'];
self::$debug = self::$debug ? self::$debug : false;
self::$ch = curl_init();
self::$headers = array('Accept' => 'application/json');
curl_setopt(self::$ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt(self::$ch, CURLOPT_SSL_VERIFYPEER, 1);
curl_setopt(self::$ch, CURLOPT_SSL_VERIFYHOST, 2);
curl_setopt(self::$ch, CURLOPT_USERAGENT, 'Podio PHP Client/' . self::VERSION);
curl_setopt(self::$ch, CURLOPT_HEADER, true);
curl_setopt(self::$ch, CURLINFO_HEADER_OUT, true);
if ($options && !empty($options['curl_options'])) {
curl_setopt_array(self::$ch, $options['curl_options']);
}
if (!Cache::has('podio_oauth')) {
self::authenticate_with_password($podio_username, $podio_password);
Cache::put('podio_oauth', Podio::$oauth, 480);
self::$oauth = Cache::get('podio_oauth');
}
// Register shutdown function for debugging and session management
register_shutdown_function('Podio::shutdown');
}
示例13: findByLocale
public function findByLocale($locale)
{
if ($this->cacheEnabled) {
$data = \Cache::get($this->getLocaleCacheKey($locale));
if (!empty($data)) {
return $data;
}
}
$siteConfiguration = SiteConfiguration::whereLocale($locale)->first();
if (!empty($siteConfiguration)) {
if ($this->cacheEnabled) {
\Cache::put($this->getLocaleCacheKey($locale), $siteConfiguration, $this->cacheLifeTime);
}
return $siteConfiguration;
}
$siteConfiguration = SiteConfiguration::whereLocale(\Config::get('app.locale'))->first();
if (!empty($siteConfiguration)) {
if ($this->cacheEnabled) {
\Cache::put($this->getLocaleCacheKey($locale), $siteConfiguration, $this->cacheLifeTime);
}
return $siteConfiguration;
}
$siteConfiguration = SiteConfiguration::orderBy('id', 'asc')->first();
if ($this->cacheEnabled) {
\Cache::put($this->getLocaleCacheKey($locale), $siteConfiguration, $this->cacheLifeTime);
}
return $siteConfiguration;
}
示例14: add_message
public function add_message(Request $request)
{
if (\Cache::has('addmsg.user.' . $this->user->id)) {
return response()->json(['errors' => 'Вы слишком часто отправляете сообщения!']);
}
\Cache::put('addmsg.user.' . $this->user->id, '', 0.05);
//$this->redis->del(self::CHAT_CHANNEL, 5);
$gameid = \DB::table('games')->max('id');
$stavki = \DB::table('bets')->where('user_id', '=', $this->user->id)->get();
//$stavki = \DB::table('bets')->where('user_id', '=' , $this->user->id)->where('game_id', '=', $gameid)->get();
if ($this->user->banchat == 1) {
return response()->json(['errors' => 'Вы забанены в чате ! Срок : Навсегда']);
}
$userid = $this->user->steamid64;
$admin = $this->user->is_admin;
$username = htmlspecialchars($this->user->username);
$avatar = $this->user->avatar;
$time = date('H:i', time());
$messages = $this->_validateMessage($request);
if ($this->user->is_admin == 0) {
if ($stavki == null) {
return response()->json(['errors' => 'Вы должны поставить ставку чтобы писать в чате']);
}
//if(strlen($messages) > 0){
//return response()->json(['errors'=>'Чат отключён']);
//}
}
function object_to_array($data)
{
if (is_array($data) || is_object($data)) {
$result = array();
foreach ($data as $key => $value) {
$result[$key] = object_to_array($value);
}
return $result;
}
return $data;
}
$words = file_get_contents(dirname(__FILE__) . '/words.json');
$words = object_to_array(json_decode($words));
foreach ($words as $key => $value) {
$messages = str_ireplace($key, $value, $messages);
}
if ($this->user->is_admin == 1) {
if (substr_count($messages, '/clear')) {
$this->redis->del(self::CHAT_CHANNEL);
\DB::table('chat')->delete();
return response()->json(['succes' => 'Вы отчистили чат']);
}
}
if (preg_match("/href|url|http|www|.ru|.com|.net|.info|.org/i", $messages)) {
return response()->json(['errors' => 'Ссылки запрещены !']);
}
$username = htmlspecialchars(preg_replace('/' . \App\Game::zapretsite() . '/i', '', $username));
$returnValue = ['userid' => $userid, 'avatar' => $avatar, 'time' => $time, 'messages' => htmlspecialchars($messages), 'username' => $username, 'admin' => $admin];
$this->redis->rpush(self::CHAT_CHANNEL, json_encode($returnValue));
$this->redis->publish(self::NEW_MSG_CHANNEL, json_encode($returnValue));
return response()->json(['succes' => 'Ваше сообщение отправлено']);
}
示例15: getActivities
public function getActivities()
{
if (!Cache::has('github')) {
$activities = $this->activity->forUser('nwidart')->activities(30);
Cache::put('github', $activities, 1440);
}
return Cache::get('github', []);
}