Example #1
0
// Init init memStore,  config is like "gcinterval=*&rmbacklog=*"
func (ms *memStore) Init(conf string) (err error) {
	c := config.NewConfig(config.LINE)
	if err = c.ParseString(conf); err == nil {
		ms.values = make(map[string]*memStoreNode)
		ms.rmChan = make(chan string, c.IntValDef(SESSION_MEM_RMBACKLOG, DEF_SESSION_MEM_RMBACKLOG))
		ms.destroyChan = make(chan bool, 1)
		ms.lock = new(sync.RWMutex)
		go ms.gc(c.IntValDef(SESSION_MEM_GCINTERVAL, DEF_SESSION_MEM_GCINTERVAL))
	}
	return
}
Example #2
0
// Load load locale data from file or dir, use base name of file as locale name
func (tr *translation) load(path string) error {
	return filepath.Walk(path, func(path string, info os.FileInfo, err error) error {
		if err == nil && !info.IsDir() {
			if name := info.Name(); filepath.Ext(name) == ".locale" {
				c := config.NewConfig(config.INI)
				if err = c.ParseFile(path); err == nil {
					if values := c.SectionVals(c.DefSec()); len(values) != 0 {
						locale := filepath.Base(name)
						tr.locales[locale] = values
					}
				}
			}
		}
		return err
	})
}