github.com/decred/politeia@v1.4.0/politeiawww/sessions/db.go (about) 1 // Copyright (c) 2021 The Decred developers 2 // Use of this source code is governed by an ISC 3 // license that can be found in the LICENSE file. 4 5 package sessions 6 7 import "errors" 8 9 var ( 10 // ErrNotFound is returned when an entry is not found in the database. 11 ErrNotFound = errors.New("session not found") 12 ) 13 14 // DB represents the database for encoded session data. 15 type DB interface { 16 // Save saves a session to the database. 17 Save(sessionID string, s EncodedSession) error 18 19 // Del deletes a session from the database. 20 // 21 // An error is not returned if the session does not exist. 22 Del(sessionID string) error 23 24 // Get gets a session from the database. 25 // 26 // An ErrNotFound error MUST be returned if a session is not found 27 // for the session ID. 28 Get(sessionID string) (*EncodedSession, error) 29 } 30 31 // EncodedSession contains a session's encoded values. 32 type EncodedSession struct { 33 Values string 34 }