riakstore

package module
Version: v0.0.0-...-88bae68 Latest Latest
Warning

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

Go to latest
Published: Dec 4, 2014 License: MIT Imports: 9 Imported by: 0

README

riakstore

A session store backend for gorilla/sessions - src using Riak.

Requirements

Depends on the Riaken riaken-core Riak library.

Installation

go get github.com/boj/riakstore

Documentation

Available on godoc.org.

See http://www.gorillatoolkit.org/pkg/sessions for full documentation on underlying interface.

Example
// Fetch new store.
addrs := []string{"127.0.0.1:8083", "127.0.0.1:8084", "127.0.0.1:8085", "127.0.0.1:8086", "127.0.0.1:8087"}
store := NewRiakStore(addrs, 5, "sessions", []byte("secret-key"))
defer store.Close()

// Get a session.
session, err := store.Get(req, "session-key")
if err != nil {
    log.Error(err.Error())
}

// Add a value.
session.Values["foo"] = "bar"

// Save.
if err = sessions.Save(req, rsp); err != nil {
    t.Fatalf("Error saving session: %v", err)
}

// Delete session.
session.Options.MaxAge = -1
if err = sessions.Save(req, rsp); err != nil {
    t.Fatalf("Error saving session: %v", err)
}

Notes

See http://docs.basho.com/riak/latest/ops/advanced/backends/multi/ for how to configure multiple backends and bucket level TTL props.

Additional FAQs on TTL:

Documentation

Overview

Package riakstore is a session store backend for gorilla/sessions using Riak.

Index

Examples

Constants

This section is empty.

Variables

View Source
var ErrNoDatabase = errors.New("no databases available")

Functions

This section is empty.

Types

type RiakStore

type RiakStore struct {
	Riaken        *riaken.Client       // riaken client
	Bucket        string               // bucket to store sessions in
	Codecs        []securecookie.Codec // session codecs
	Options       *sessions.Options    // default configuration
	DefaultMaxAge int                  // default TTL for a MaxAge == 0 session
}

RiakStore stores sessions in a redis backend.

Example
// RiakStore
addrs := []string{"127.0.0.1:8083", "127.0.0.1:8084", "127.0.0.1:8085", "127.0.0.1:8086", "127.0.0.1:8087"}
store := NewRiakStore(addrs, 5, "sessions", []byte("secret-key"))
defer store.Close()
Output:

func NewRiakStore

func NewRiakStore(addrs []string, connections int, bucket string, keyPairs ...[]byte) *RiakStore

NewRiakStore returns a new RiakStore.

func (*RiakStore) Close

func (s *RiakStore) Close()

Close closes the underlying Riaken Client.

func (*RiakStore) Get

func (s *RiakStore) Get(r *http.Request, name string) (*sessions.Session, error)

Get returns a session for the given name after adding it to the registry.

func (*RiakStore) New

func (s *RiakStore) New(r *http.Request, name string) (*sessions.Session, error)

New returns a session for the given name without adding it to the registry.

func (*RiakStore) Save

func (s *RiakStore) Save(r *http.Request, w http.ResponseWriter, session *sessions.Session) error

Save adds a single session to the response.

Jump to

Keyboard shortcuts

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