Version: v1.5.0 Latest Latest

This package is not in the latest version of its module.

Go to latest
Published: Nov 8, 2018 License: MIT Imports: 3 Imported by: 0



Package boltstore is a boltdb based session store for the SCS session package.



This section is empty.


This section is empty.


This section is empty.


type BoltStore

type BoltStore struct {
	// contains filtered or unexported fields

BoltStore is a SCS session store backed by a boltdb file.

func New

func New(db *bolt.DB, cleanupInterval time.Duration) *BoltStore

New creates a BoltStore instance.

The cleanupInterval parameter controls how frequently expired session data is removed by the background cleanup goroutine. Setting it to 0 prevents the cleanup goroutine from running (i.e. expired sessions will not be removed).

func (*BoltStore) Delete

func (bs *BoltStore) Delete(token string) error

Delete removes session token and corresponding data.

func (*BoltStore) Find

func (bs *BoltStore) Find(token string) (b []byte, exists bool, err error)

Find returns the data for a session token. If the session token is not found or is expired, the exists flag will be false.

func (*BoltStore) Save

func (bs *BoltStore) Save(token string, b []byte, expiry time.Time) error

Save updates data for a given session token with a given expiry. Any existing data + expiry will be over-written.

func (*BoltStore) StopCleanup

func (bs *BoltStore) StopCleanup()

StopCleanup terminates the background cleanup goroutine for the BoltStore instance. It's rare to terminate this; generally BoltStore instances and their cleanup goroutines are intended to be long-lived and run for the lifetime of your application.

There may be occasions though when your use of the BoltStore is transient. An example is creating a new BoltStore instance in a test function. In this scenario, the cleanup goroutine (which will run forever) will prevent the BoltStore object from being garbage collected even after the test function has finished. You can prevent this by manually calling StopCleanup.

Source Files

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL