file

package
v2.1.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2017 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DefaultFileMode = 0666
)

DefaultFileMode used as the default database's "fileMode" for creating the sessions directory path, opening and write the session file.

Functions

This section is empty.

Types

type Database

type Database struct {
	// contains filtered or unexported fields
}

Database is the basic file-storage session database.

What it does It removes old(expired) session files, at init (`Cleanup`). It creates a session file on the first inserted key-value session data. It removes a session file on destroy. It sync the session file to the session's memstore on any other action (insert, delete, clear). It automatically remove the session files on runtime when a session is expired.

Remember: sessions are not a storage for large data, everywhere: on any platform on any programming language.

func New

func New(directoryPath string, fileMode os.FileMode) (*Database, error)

New creates and returns a new file-storage database instance based on the "directoryPath". DirectoryPath should is the directory which the leveldb database will store the sessions, i.e ./sessions/

It will remove any old session files.

func (*Database) Async

func (db *Database) Async(useGoRoutines bool) *Database

Async if true passed then it will use go routines to: append or re-write a file create a file remove a file.

Defaults to false.

func (*Database) Cleanup

func (db *Database) Cleanup() error

Cleanup removes any invalid(have expired) session files, it's being called automatically on `New` as well.

func (*Database) FileMode

func (db *Database) FileMode(fileMode uint32) *Database

FileMode for creating the sessions directory path, opening and write the session file.

Defaults to 0666.

func (*Database) Load

func (db *Database) Load(sid string) sessions.RemoteStore

Load loads the values from the storage and returns them

func (*Database) Sync

func (db *Database) Sync(p sessions.SyncPayload)

Sync syncs the database.

Jump to

Keyboard shortcuts

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