Primo Committ
This commit is contained in:
81
vendor/laravel/framework/src/Illuminate/Cache/Console/CacheTableCommand.php
vendored
Normal file
81
vendor/laravel/framework/src/Illuminate/Cache/Console/CacheTableCommand.php
vendored
Normal file
@@ -0,0 +1,81 @@
|
||||
<?php
|
||||
|
||||
namespace Illuminate\Cache\Console;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Filesystem\Filesystem;
|
||||
use Illuminate\Support\Composer;
|
||||
|
||||
class CacheTableCommand extends Command
|
||||
{
|
||||
/**
|
||||
* The console command name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $name = 'cache:table';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Create a migration for the cache database table';
|
||||
|
||||
/**
|
||||
* The filesystem instance.
|
||||
*
|
||||
* @var \Illuminate\Filesystem\Filesystem
|
||||
*/
|
||||
protected $files;
|
||||
|
||||
/**
|
||||
* @var \Illuminate\Support\Composer
|
||||
*/
|
||||
protected $composer;
|
||||
|
||||
/**
|
||||
* Create a new cache table command instance.
|
||||
*
|
||||
* @param \Illuminate\Filesystem\Filesystem $files
|
||||
* @param \Illuminate\Support\Composer $composer
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(Filesystem $files, Composer $composer)
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
$this->files = $files;
|
||||
$this->composer = $composer;
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$fullPath = $this->createBaseMigration();
|
||||
|
||||
$this->files->put($fullPath, $this->files->get(__DIR__.'/stubs/cache.stub'));
|
||||
|
||||
$this->info('Migration created successfully!');
|
||||
|
||||
$this->composer->dumpAutoloads();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a base migration file for the table.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function createBaseMigration()
|
||||
{
|
||||
$name = 'create_cache_table';
|
||||
|
||||
$path = $this->laravel->databasePath().'/migrations';
|
||||
|
||||
return $this->laravel['migration.creator']->create($name, $path);
|
||||
}
|
||||
}
|
||||
145
vendor/laravel/framework/src/Illuminate/Cache/Console/ClearCommand.php
vendored
Executable file
145
vendor/laravel/framework/src/Illuminate/Cache/Console/ClearCommand.php
vendored
Executable file
@@ -0,0 +1,145 @@
|
||||
<?php
|
||||
|
||||
namespace Illuminate\Cache\Console;
|
||||
|
||||
use Illuminate\Cache\CacheManager;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Filesystem\Filesystem;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
|
||||
class ClearCommand extends Command
|
||||
{
|
||||
/**
|
||||
* The console command name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $name = 'cache:clear';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Flush the application cache';
|
||||
|
||||
/**
|
||||
* The cache manager instance.
|
||||
*
|
||||
* @var \Illuminate\Cache\CacheManager
|
||||
*/
|
||||
protected $cache;
|
||||
|
||||
/**
|
||||
* The filesystem instance.
|
||||
*
|
||||
* @var \Illuminate\Filesystem\Filesystem
|
||||
*/
|
||||
protected $files;
|
||||
|
||||
/**
|
||||
* Create a new cache clear command instance.
|
||||
*
|
||||
* @param \Illuminate\Cache\CacheManager $cache
|
||||
* @param \Illuminate\Filesystem\Filesystem $files
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(CacheManager $cache, Filesystem $files)
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
$this->cache = $cache;
|
||||
$this->files = $files;
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$this->laravel['events']->dispatch(
|
||||
'cache:clearing', [$this->argument('store'), $this->tags()]
|
||||
);
|
||||
|
||||
$successful = $this->cache()->flush();
|
||||
|
||||
$this->flushFacades();
|
||||
|
||||
if (! $successful) {
|
||||
return $this->error('Failed to clear cache. Make sure you have the appropriate permissions.');
|
||||
}
|
||||
|
||||
$this->laravel['events']->dispatch(
|
||||
'cache:cleared', [$this->argument('store'), $this->tags()]
|
||||
);
|
||||
|
||||
$this->info('Application cache cleared!');
|
||||
}
|
||||
|
||||
/**
|
||||
* Flush the real-time facades stored in the cache directory.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function flushFacades()
|
||||
{
|
||||
if (! $this->files->exists($storagePath = storage_path('framework/cache'))) {
|
||||
return;
|
||||
}
|
||||
|
||||
foreach ($this->files->files($storagePath) as $file) {
|
||||
if (preg_match('/facade-.*\.php$/', $file)) {
|
||||
$this->files->delete($file);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the cache instance for the command.
|
||||
*
|
||||
* @return \Illuminate\Cache\Repository
|
||||
*/
|
||||
protected function cache()
|
||||
{
|
||||
$cache = $this->cache->store($this->argument('store'));
|
||||
|
||||
return empty($this->tags()) ? $cache : $cache->tags($this->tags());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the tags passed to the command.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function tags()
|
||||
{
|
||||
return array_filter(explode(',', $this->option('tags')));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the console command arguments.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function getArguments()
|
||||
{
|
||||
return [
|
||||
['store', InputArgument::OPTIONAL, 'The name of the store you would like to clear'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the console command options.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function getOptions()
|
||||
{
|
||||
return [
|
||||
['tags', null, InputOption::VALUE_OPTIONAL, 'The cache tags you would like to clear', null],
|
||||
];
|
||||
}
|
||||
}
|
||||
57
vendor/laravel/framework/src/Illuminate/Cache/Console/ForgetCommand.php
vendored
Executable file
57
vendor/laravel/framework/src/Illuminate/Cache/Console/ForgetCommand.php
vendored
Executable file
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
|
||||
namespace Illuminate\Cache\Console;
|
||||
|
||||
use Illuminate\Cache\CacheManager;
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
class ForgetCommand extends Command
|
||||
{
|
||||
/**
|
||||
* The console command name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'cache:forget {key : The key to remove} {store? : The store to remove the key from}';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Remove an item from the cache';
|
||||
|
||||
/**
|
||||
* The cache manager instance.
|
||||
*
|
||||
* @var \Illuminate\Cache\CacheManager
|
||||
*/
|
||||
protected $cache;
|
||||
|
||||
/**
|
||||
* Create a new cache clear command instance.
|
||||
*
|
||||
* @param \Illuminate\Cache\CacheManager $cache
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(CacheManager $cache)
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
$this->cache = $cache;
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$this->cache->store($this->argument('store'))->forget(
|
||||
$this->argument('key')
|
||||
);
|
||||
|
||||
$this->info('The ['.$this->argument('key').'] key has been removed from the cache.');
|
||||
}
|
||||
}
|
||||
32
vendor/laravel/framework/src/Illuminate/Cache/Console/stubs/cache.stub
vendored
Normal file
32
vendor/laravel/framework/src/Illuminate/Cache/Console/stubs/cache.stub
vendored
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateCacheTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('cache', function (Blueprint $table) {
|
||||
$table->string('key')->unique();
|
||||
$table->mediumText('value');
|
||||
$table->integer('expiration');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('cache');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user