Exemple #1
0
// Create a new session.
func (s *store) Create() (sessionID storage.ID, err error) {
	u := uuid.NewV4()

	sessionID_ := storage.ID(u.Bytes())
	err = s.set(sessionID_, map[string]interface{}{}, true)
	if err != nil {
		return
	}

	sessionID = sessionID_
	return
}
Exemple #2
0
// Create a new session and return the ID.
func (s *store) Create() (sessionID storage.ID, err error) {
	if s.cfg.FallbackStore != nil {
		sessionID, err = s.cfg.FallbackStore.Create()
	}

	// resilience: go from memory on fallback store failure
	if s.cfg.FallbackStore == nil || err != nil {
		u := uuid.NewV4()
		if u == nil {
			log.Panic("cannot create UUID")
		}

		sessionID = storage.ID(u.Bytes())
	}

	s.storeMutex.Lock()
	defer s.storeMutex.Unlock()
	s.lCreatingSet(sessionID, map[string]interface{}{})
	return
}