ledislocal

package module
v0.0.0-...-dd846c0 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2024 License: MIT Imports: 11 Imported by: 0

README

session-ledis-local Build Status

Session-ledis-local is a store of session middleware for Tango stored session data via ledisdb.

Installation

go get gitea.com/tango/session-ledis-local

Simple Example

package main

import (
    "gitea.com/lunny/tango"
    "gitea.com/tango/session"
    "gitea.com/tango/session-ledis-local"
)

type SessionAction struct {
    session.Session
}

func (a *SessionAction) Get() string {
    a.Session.Set("test", "1")
    return a.Session.Get("test").(string)
}

func main() {
    o := tango.Classic()
    store, _ := ledislocal.New(ledislocal.Options{
        Path:    "./ledis_store",
        DBIndex: 0,
        MaxAge:  30 * time.Minute,
    })
    o.Use(session.New(session.Options{
        Store: store,
        }))
    o.Get("/", new(SessionAction))
}

Getting Help

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type LedisLocalStore

type LedisLocalStore struct {
	Options
	tango.Logger
	// contains filtered or unexported fields
}

LedisLocalStore represents a ledis local session store implementation.

func New

func New(opts ...Options) (*LedisLocalStore, error)

New creates and returns a redis session store.

func (*LedisLocalStore) Add

func (s *LedisLocalStore) Add(id session.Id) bool

func (*LedisLocalStore) Clear

func (s *LedisLocalStore) Clear(id session.Id) bool

func (*LedisLocalStore) Del

func (s *LedisLocalStore) Del(id session.Id, key string) bool

Del delete a key from session.

func (*LedisLocalStore) Exist

func (s *LedisLocalStore) Exist(id session.Id) bool

func (*LedisLocalStore) Get

func (s *LedisLocalStore) Get(id session.Id, key string) interface{}

Get gets value by given key in session.

func (*LedisLocalStore) Keys

func (s *LedisLocalStore) Keys(id session.Id) ([]string, error)

Keys gets all keys of the session.

func (*LedisLocalStore) Run

func (s *LedisLocalStore) Run() error

func (*LedisLocalStore) Set

func (s *LedisLocalStore) Set(id session.Id, key string, val interface{}) error

Set sets value to given key in session.

func (*LedisLocalStore) SetIdMaxAge

func (s *LedisLocalStore) SetIdMaxAge(id session.Id, maxAge time.Duration)

func (*LedisLocalStore) SetMaxAge

func (s *LedisLocalStore) SetMaxAge(maxAge time.Duration)

type Options

type Options struct {
	Path    string
	DBIndex int
	MaxAge  time.Duration
}

Jump to

Keyboard shortcuts

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