Exemple #1
0
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())
}
Exemple #2
0
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
}
Exemple #3
0
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)
}