dgraphstore

package module
v1.0.1-0...-1b56118 Latest Latest
Warning

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

Go to latest
Published: Mar 11, 2023 License: Unlicense Imports: 11 Imported by: 8

Documentation

Index

Constants

This section is empty.

Variables

DefaultGRPCDialOptions is used on `grpc.Dial` call of the `New` package-level function.

Functions

This section is empty.

Types

type Database

type Database struct {
	Service *dgo.Dgraph
	// contains filtered or unexported fields
}

Database the BoltDB(file-based) session storage.

func New

func New(target string) (*Database, error)

New creates and returns a new Dgraph database connection to "target" with the DefaultGRPCDialOptions, which contains `insecure.NewCredentials()`. Target should include the url to Dgraph's alpha gRPC-external-public port.

It will remove any old session files.

func NewFromDB

func NewFromDB(conn *grpc.ClientConn) (*Database, error)

NewFromDB same as `New` but accepts an already-created secured gRPC connection instead.

func (*Database) Acquire

func (db *Database) Acquire(sid string, expires time.Duration) sessions.LifeTime

Acquire receives a session's lifetime from the database, if the return value is LifeTime{} then the session manager sets the life time based on the expiration duration lives in configuration.

func (*Database) Clear

func (db *Database) Clear(sid string) error

Clear removes all session key values but it keeps the session entry.

func (*Database) Close

func (db *Database) Close() error

Close terminates Dgraph's gRPC connection.

func (*Database) Decode

func (db *Database) Decode(sid, key string, outPtr interface{}) error

Decode binds the "outPtr" to the value associated to the provided "key".

func (*Database) Delete

func (db *Database) Delete(sid string, key string) (deleted bool)

Delete removes a session key value based on its key.

func (*Database) Get

func (db *Database) Get(sid string, key string) (value interface{})

Get retrieves a session value based on the key.

func (*Database) Len

func (db *Database) Len(sid string) (n int)

Len returns the length of the session's entries (keys).

func (*Database) OnUpdateExpiration

func (db *Database) OnUpdateExpiration(sid string, newExpires time.Duration) error

OnUpdateExpiration not implemented here, yet. Note that this error will not be logged, callers should catch it manually.

func (*Database) Release

func (db *Database) Release(sid string) error

Release destroys the session, it clears and removes the session entry, session manager will create a new session ID on the next request after this call.

func (*Database) Set

func (db *Database) Set(sid string, key string, value interface{}, dur time.Duration, immutable bool) error

Set sets a key value of a specific session. Ignore the "immutable".

func (*Database) SetLogger

func (db *Database) SetLogger(logger *golog.Logger)

SetLogger sets the logger once before server ran. By default the Iris one is injected.

func (*Database) Visit

func (db *Database) Visit(sid string, cb func(key string, value interface{})) error

Visit loops through all session keys and values.

Jump to

Keyboard shortcuts

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