boltstore

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2017 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

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

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

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.

Jump to

Keyboard shortcuts

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