github.com/goravel/framework@v1.13.9/cache/console/clear_command.go (about) 1 package console 2 3 import ( 4 "github.com/gookit/color" 5 6 "github.com/goravel/framework/contracts/cache" 7 "github.com/goravel/framework/contracts/console" 8 "github.com/goravel/framework/contracts/console/command" 9 ) 10 11 type ClearCommand struct { 12 cache cache.Cache 13 } 14 15 func NewClearCommand(cache cache.Cache) *ClearCommand { 16 return &ClearCommand{cache: cache} 17 } 18 19 //Signature The name and signature of the console command. 20 func (receiver *ClearCommand) Signature() string { 21 return "cache:clear" 22 } 23 24 //Description The console command description. 25 func (receiver *ClearCommand) Description() string { 26 return "Flush the application cache" 27 } 28 29 //Extend The console command extend. 30 func (receiver *ClearCommand) Extend() command.Extend { 31 return command.Extend{ 32 Category: "cache", 33 } 34 } 35 36 //Handle Execute the console command. 37 func (receiver *ClearCommand) Handle(ctx console.Context) error { 38 if receiver.cache.Flush() { 39 color.Greenln("Application cache cleared") 40 } else { 41 color.Redln("Clear Application cache Failed") 42 } 43 44 return nil 45 }