Esempio n. 1
0
func (g *GlobalContext) ConfigureCaches() error {
	g.ResolveCache = NewResolveCache()
	g.IdentifyCache = NewIdentifyCache()
	g.UserCache = NewUserCache(g.Env.GetUserCacheMaxAge())
	g.ProofCache = NewProofCache(g.Env.GetProofCacheSize())
	g.FavoriteCache = favcache.New()

	// We consider the local DB as a cache; it's caching our
	// fetches from the server after all (and also our cryptographic
	// checking).
	g.LocalDb = NewJSONLocalDb(NewLevelDb(g))
	return g.LocalDb.Open()
}
Esempio n. 2
0
func (g *GlobalContext) Logout() error {
	g.loginStateMu.Lock()
	defer g.loginStateMu.Unlock()
	if err := g.loginState.Logout(); err != nil {
		return err
	}

	if g.IdentifyCache != nil {
		g.IdentifyCache.Shutdown()
	}
	if g.UserCache != nil {
		g.UserCache.Shutdown()
	}
	g.IdentifyCache = NewIdentifyCache()
	g.UserCache = NewUserCache(g.Env.GetUserCacheMaxAge())
	g.FavoriteCache = favcache.New()

	// get a clean LoginState:
	g.createLoginStateLocked()

	return nil
}