Beispiel #1
0
// register registers itself (the new provider with its memory store) to the sessions providers
// must runs only once
func register() {
	// the actual work is here.
	Provider.NewStore = func(sessionId string, cookieLifeDuration time.Duration) store.IStore {
		return &Store{sid: sessionId, lastAccessedTime: time.Now(), values: make(map[string]interface{}, 0)}
	}
	sessions.Register(Provider)
}
Beispiel #2
0
// register registers itself (the new provider with its memory store) to the sessions providers
// must runs only once
func register() {
	// the actual work is here.
	Provider.NewStore = func(sessionId string, cookieLifeDuration time.Duration) store.IStore {
		//println("memory.go:49-> requesting new memory store with sessionid: " + sessionId)
		if !redis.Connected {
			redis.Connect()
			_, err := redis.PingPong()
			if err != nil {
				if err != nil {
					// don't use to get the logger, just prin these to the console... atm
					println("Redis Connection error on iris/sessions/providers/redisstore.Connect: " + err.Error())
					println("But don't panic, auto-switching to memory store right now!")
				}
			}
		}
		return NewStore(sessionId, cookieLifeDuration)
	}

	sessions.Register(Provider)
}