mirror of
https://github.com/taigrr/jety.git
synced 2026-04-01 19:08:58 -07:00
optimistic writeback and pessimistic read
This commit is contained in:
@@ -9,6 +9,7 @@ func (c *ConfigManager) SetBool(key string, value bool) {
|
||||
defer c.mutex.Unlock()
|
||||
lower := strings.ToLower(key)
|
||||
c.mapConfig[lower] = ConfigMap{Key: key, Value: value}
|
||||
c.combinedConfig[lower] = ConfigMap{Key: key, Value: value}
|
||||
}
|
||||
|
||||
func (c *ConfigManager) SetString(key string, value string) {
|
||||
@@ -16,6 +17,7 @@ func (c *ConfigManager) SetString(key string, value string) {
|
||||
defer c.mutex.Unlock()
|
||||
lower := strings.ToLower(key)
|
||||
c.mapConfig[lower] = ConfigMap{Key: key, Value: value}
|
||||
c.combinedConfig[lower] = ConfigMap{Key: key, Value: value}
|
||||
}
|
||||
|
||||
func (c *ConfigManager) Set(key string, value any) {
|
||||
@@ -23,6 +25,7 @@ func (c *ConfigManager) Set(key string, value any) {
|
||||
defer c.mutex.Unlock()
|
||||
lower := strings.ToLower(key)
|
||||
c.mapConfig[lower] = ConfigMap{Key: key, Value: value}
|
||||
c.combinedConfig[lower] = ConfigMap{Key: key, Value: value}
|
||||
}
|
||||
|
||||
func (c *ConfigManager) SetDefault(key string, value any) {
|
||||
@@ -30,4 +33,10 @@ func (c *ConfigManager) SetDefault(key string, value any) {
|
||||
defer c.mutex.Unlock()
|
||||
lower := strings.ToLower(key)
|
||||
c.defaultConfig[lower] = ConfigMap{Key: key, Value: value}
|
||||
if _, ok := c.mapConfig[lower]; !ok {
|
||||
if envVal, ok := c.envConfig[lower]; !ok {
|
||||
c.mapConfig[lower] = envVal
|
||||
c.combinedConfig[lower] = envVal
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user