github.com/lmorg/murex@v0.0.0-20240217211045-e081c89cd4ef/utils/cache/config.go (about) 1 package cache 2 3 import ( 4 "fmt" 5 6 "github.com/lmorg/murex/lang/types" 7 ) 8 9 var configCacheDisabled bool 10 11 // ReadMimes returns boolean 12 // This is only intended to be used by `config.Properties.GoFunc.Read()` 13 func ReadStatus() (interface{}, error) { 14 return !configCacheDisabled && !disabled, nil 15 } 16 17 // WriteStatus takes a bool 18 // This is only intended to be used by `config.Properties.GoFunc.Write()` 19 func WriteStatus(v interface{}) error { 20 v, err := types.ConvertGoType(v, types.Boolean) 21 22 if err != nil { 23 return err 24 } 25 26 boolean, ok := v.(bool) 27 28 if !ok { 29 return fmt.Errorf("cannot set cache enabled value because value is not a boolean") 30 } 31 32 configCacheDisabled = !boolean 33 34 return nil 35 }