ForgetCommand.php 1.2KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. <?php
  2. namespace Illuminate\Cache\Console;
  3. use Illuminate\Console\Command;
  4. use Illuminate\Cache\CacheManager;
  5. class ForgetCommand extends Command
  6. {
  7. /**
  8. * The console command name.
  9. *
  10. * @var string
  11. */
  12. protected $signature = 'cache:forget {key : The key to remove} {store? : The store to remove the key from}';
  13. /**
  14. * The console command description.
  15. *
  16. * @var string
  17. */
  18. protected $description = 'Remove an item from the cache';
  19. /**
  20. * The cache manager instance.
  21. *
  22. * @var \Illuminate\Cache\CacheManager
  23. */
  24. protected $cache;
  25. /**
  26. * Create a new cache clear command instance.
  27. *
  28. * @param \Illuminate\Cache\CacheManager $cache
  29. * @return void
  30. */
  31. public function __construct(CacheManager $cache)
  32. {
  33. parent::__construct();
  34. $this->cache = $cache;
  35. }
  36. /**
  37. * Execute the console command.
  38. *
  39. * @return void
  40. */
  41. public function handle()
  42. {
  43. $this->cache->store($this->argument('store'))->forget(
  44. $this->argument('key')
  45. );
  46. $this->info('The ['.$this->argument('key').'] key has been removed from the cache.');
  47. }
  48. }