ssdbstore

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

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

Go to latest
Published: Feb 14, 2017 License: BSD-3-Clause Imports: 11 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

session-ssdb Build Status

Session-ssdb is a store of session middleware for Tango stored session data via ssdb.

Known issue

See https://github.com/tango-contrib/session-ssdb/issues/1

Installation

go get github.com/tango-contrib/session-ssdb

Simple Example

package main

import (
    "github.com/lunny/tango"
    "github.com/tango-contrib/session"
    "github.com/tango-contrib/session-ssdb"
)

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, err := ssdbstore.New(redistore.Options{
            Host:    "127.0.0.1",
            DbIndex: 0,
            MaxAge:  30 * time.Minute,
        }
    o.Use(session.New(session.Options{
        Store: store),
        }))
    o.Get("/", new(SessionAction))
}

Getting Help

License

This project is under BSD License. See the LICENSE file for the full license text.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Options

type Options struct {
	Host     string
	Port     int
	Password string
	DbIndex  int
	MaxAge   time.Duration
}

type SSDBStore

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

SSDBStore represents a redis session store implementation.

func New

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

NewSSDBStore creates and returns a redis session store.

func (*SSDBStore) Add

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

func (*SSDBStore) Clear

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

func (*SSDBStore) Del

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

Delete delete a key from session.

func (*SSDBStore) Exist

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

func (*SSDBStore) Get

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

Get gets value by given key in session.

func (*SSDBStore) Ping

func (s *SSDBStore) Ping() error

func (*SSDBStore) Run

func (s *SSDBStore) Run() error

func (*SSDBStore) Set

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

Set sets value to given key in session.

func (*SSDBStore) SetIdMaxAge

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

func (*SSDBStore) SetMaxAge

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

Jump to

Keyboard shortcuts

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