redistore

package module
v0.0.0-...-54d5e6b Latest Latest
Warning

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

Go to latest
Published: May 16, 2016 License: BSD-3-Clause Imports: 10 Imported by: 0

README

session-redis Build Status

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

Installation

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

Simple Example

package main

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

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()
    o.Use(session.New(session.Options{
        Store: redistore.New(redistore.Options{
                Host:    "127.0.0.1",
                DbIndex: 0,
                MaxAge:  30 * time.Minute,
            }),
        }))
    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      string
	Password  string
	DbIndex   int
	MaxAge    time.Duration
	KeyPrefix string
}

type RedisStore

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

RedisStore represents a redis session store implementation.

func New

func New(opts ...Options) *RedisStore

NewRedisStore creates and returns a redis session store.

func (*RedisStore) Add

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

func (*RedisStore) Clear

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

func (*RedisStore) Del

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

Delete delete a key from session.

func (*RedisStore) Do

func (s *RedisStore) Do(cmd string, args ...interface{}) (interface{}, error)

func (*RedisStore) Exist

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

func (*RedisStore) Get

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

Get gets value by given key in session.

func (*RedisStore) Ping

func (s *RedisStore) Ping() error

func (*RedisStore) Run

func (s *RedisStore) Run() error

func (*RedisStore) Set

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

Set sets value to given key in session.

func (*RedisStore) SetIdMaxAge

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

func (*RedisStore) SetMaxAge

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

Jump to

Keyboard shortcuts

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