From 1edf40675dbf9a986a23cd5205a8395cc05f740b Mon Sep 17 00:00:00 2001 From: Daniel Brendel Date: Sat, 23 Nov 2024 02:35:55 +0100 Subject: [PATCH] Clear cache command --- app/commands/CacheClearCommand.php | 32 ++++++++++++++++++++++++++++++ app/config/commands.php | 3 ++- app/models/CacheModel.php | 10 ++++++++++ 3 files changed, 44 insertions(+), 1 deletion(-) create mode 100644 app/commands/CacheClearCommand.php diff --git a/app/commands/CacheClearCommand.php b/app/commands/CacheClearCommand.php new file mode 100644 index 00000000..70094e1c --- /dev/null +++ b/app/commands/CacheClearCommand.php @@ -0,0 +1,32 @@ +getMessage()}\033[39m\n"; + + return; + } + + echo "\033[32mDone!\033[39m\n"; + } +} + \ No newline at end of file diff --git a/app/config/commands.php b/app/config/commands.php index bd8a315e..9c12c25f 100644 --- a/app/config/commands.php +++ b/app/config/commands.php @@ -17,5 +17,6 @@ ['product:version', 'Show current product version', 'VersionCommand'], ['migrate:upgrade', 'Perform version specific migration upgrades', 'MigrationUpgrade'], ['calendar:classes', 'Add default calendar classes', 'CalendarClsCommand'], - ['plants:attributes', 'Add default plant attributes', 'AttributesCommand'] + ['plants:attributes', 'Add default plant attributes', 'AttributesCommand'], + ['cache:clear', 'Clear the entire cache', 'CacheClearCommand'] ]; diff --git a/app/models/CacheModel.php b/app/models/CacheModel.php index 3765bdbc..ed609eda 100644 --- a/app/models/CacheModel.php +++ b/app/models/CacheModel.php @@ -135,6 +135,16 @@ public static function forget($ident) return false; } + + /** + * Clear entire cache + * + * @return void + */ + public static function clear() + { + static::raw('DELETE FROM `' . self::tableName() . '`'); + } /** * Return the associated table name of the migration