laravel cache() - get()在命令中不起作用

时间:2018-04-30 04:12:07

标签: php laravel laravel-5 laravel-5.6

我使用命令<?php namespace App\Console\Commands; use Illuminate\Console\Command; class RedisDataListener extends Command { /** * The name and signature of the console command. * * @var string */ protected $signature = 'listen:subscribe'; /** * The console command description. * * @var string */ protected $description = 'Subscribe to redis channel for listening events'; /** * Create a new command instance. * * @return void */ public function __construct() { parent::__construct(); } /** * Execute the console command. * * @return mixed */ public function handle() { $value = cache()->has('tracking_application:mykey') ? cache()->get('tracking_application:mykey') : 'no'; print_r(array( $value )); } }

在laravel中创建了以下命令
  availableCars:number = null;
  @Input() availableCarsNumber: number = null;

  //This property setter is called anytime the input property changes
  @Input() set totalCarsNumber(val: number){
    if(this.availableCarsNumber === null){
     this.availableCarsNumber = val;
    }
    this.availableCars = val;
  }

  //This getter is called when reading and displaying data
  get totalCarsNumber(){
    return this.availableCars;
  }

但是当我使用cache() - &gt; get('key')时,它无效。当我在控制器中使用时,相同的功能正常工作。

我正在使用redis作为缓存服务器。 还尝试使用cache :: get()但没有任何反应。

0 个答案:

没有答案