scs: Index | Files

package boltstore

import ""

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


Package Files


type BoltStore Uses

type BoltStore struct {
    // contains filtered or unexported fields

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

func New Uses

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 Uses

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

Delete removes session token and corresponding data.

func (*BoltStore) Find Uses

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 Uses

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 Uses

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.

Package boltstore imports 3 packages (graph) and is imported by 1 packages. Updated 2017-09-01. Refresh now. Tools for package owners.