func (c *Client) commit(fn func(*config.Cache) error) error { if c.Cache != nil { return fn(c.Cache) } cache := config.NewCache(c.cacheOpts()) return nonil(fn(cache), cache.Close()) }
func (c *Client) Cache() *cfg.Cache { if c.cache != nil { return c.cache } c.cache = cfg.NewCache(configstore.CacheOptions("kd")) ctlcli.CloseOnExit(c.cache) return c.cache }
func (c *Client) initClient() { c.store = &configstore.Client{} c.cache = config.NewCache(c.store.CacheOptions("konfig")) c.defaults = make(config.Konfigs) c.store.Cache = c.cache // Ignoring read error, if it's non-nil then empty cache is going to // be used instead. _ = c.cache.GetValue("konfigs.default", &c.defaults) // Flush cache on exit. ctlcli.CloseOnExit(c) }