Ejemplo n.º 1
0
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle()
 {
     $a = Redis::command("KEYS", ['q*']);
     foreach ($a as $cmd) {
         $q = $cmd;
         $t = Redis::command('TYPE', [$q]);
         if ($t == 'zset') {
             $count = Redis::command('ZCARD', [$q]);
         } else {
             if ($t == 'list') {
                 $count = Redis::command('LLEN', [$q]);
             } else {
                 $count = 'x';
             }
         }
         $this->info($cmd . ' ' . $t . ' ' . $count);
     }
     if (count($a)) {
         $abort = $this->option('force');
         if ($abort || $this->ask("Abort queues (y/N)?", 'N') == 'y') {
             $this->comment("Aborting...");
             foreach ($a as $cmd) {
                 Redis::command("DEL", [$cmd]);
             }
             $this->comment("Aborted");
         }
     } else {
         $this->info('Queues not found');
     }
 }
Ejemplo n.º 2
0
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     $keys = Redis::keys(env('CACHE_PREFIX') . '*');
     $values = $keys ? Redis::command('MGET', $keys) : [];
     $result = array_filter(array_map(function ($json) {
         return json_decode($json);
     }, $values));
     return response()->json($result);
 }
Ejemplo n.º 3
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($motto)
 {
     $result = Redis::command('SREM', ['mottos', $motto]);
     if ($result) {
         return redirect('/admin/motto')->with('message', '删除博客签名成功.');
     } else {
         return redirect('/admin/motto')->with('message', '添加博客签名失败.');
     }
 }
Ejemplo n.º 4
0
 /**
  * @param int $start
  * @param int $end
  * @param string $view
  *
  * @return \Illuminate\View\View
  */
 protected function linkView($start, $end, $view)
 {
     $links = [];
     for ($i = $start; $i <= $end; $i += 1) {
         $hash = 'link:' . $i;
         $title = Redis::command('hget', [$hash, 'title']);
         if ($title !== null) {
             $links[$i] = $title;
         }
     }
     return view($view, ['links' => $links]);
 }
Ejemplo n.º 5
0
 private function clear_articels_cache()
 {
     $pages = Redis::command('lrange', ['welcome:articles:pages', 0, -1]);
     foreach ($pages as $cache_key) {
         if (Cache::has($cache_key)) {
             Cache::forget($cache_key);
         }
     }
     Redis::command('del', ['welcome:articles:pages']);
     Cache::forget('self:rss');
     Cache::forget('self:archive');
     Cache::forget('self::categorie');
 }
Ejemplo n.º 6
0
 /**
  * 用于博客主页文章的显示
  */
 public function welcome(Request $request)
 {
     $page = $request->input('page', 1);
     $key = "welcome:articles:" . $page;
     if (Cache::has($key)) {
         Log::info("从缓存中取得数据.");
         $articles = Cache::get($key);
     } else {
         Log::info("缓存中没有数据,从DB取得数据,并放入缓存中.");
         $articles = Article::orderBy('created_at', 'desc')->paginate();
         $expiresAt = Carbon::now()->addMinute(30);
         Cache::put($key, $articles, $expiresAt);
         Redis::command('rpush', ['welcome:articles:pages', $key]);
     }
     return view('welcome')->with('articles', $articles);
 }
Ejemplo n.º 7
0
					</div>
					<button type="submit" class="btn btn-default">搜索</button>
				</form>

			</div>
			<!-- /.navbar-collapse -->
		</div>
		<!-- /.container-fluid -->
	</nav>

	<div class="container">

		<div class="blog-header">
			<h1 class="blog-title">LuBlog</h1>
			<p class="lead blog-description"><?php 
$motto = Redis::command('SRANDMEMBER', ['mottos']);
if ($motto) {
    echo $motto;
}
?>
</p>
		</div>

		<div class="row">

			<div class="col-sm-8 blog-main">@yield('content')</div>
			<!-- /.blog-main -->
			<div class="col-sm-3 col-sm-offset-1 blog-sidebar">
				@section('subject_des')
				<div class="sidebar-module sidebar-module-inset">
					<h4>联系博主</h4>