Skip to content

boj/rethinkstore

master
Switch branches/tags
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
 
 
 
 

rethinkstore Build Status

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

Requirements

Depends on the gorethink library.

Installation

go get github.com/boj/rethinkstore

Documentation

Available on godoc.org.

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

Example

// Fetch new store.
store, err := NewRethinkStore("127.0.0.1:28015",
                              "my-db",
                              "my-session-table",
                              5 /*MaxIdle*/,
                              5 /*MaxOpen*/,
                              []byte("secret-key"))
if err != nil {
    panic(err)
}
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, but not from the store
session.Options.MaxAge = -1
if err = sessions.Save(req, rsp); err != nil {
    t.Fatalf("Error saving session: %v", err)
}

// Delete expired data. Call this function periodically
session.Options.MaxAge = -1
if err = store.DeleteExpired(); err != nil {
    t.Fatalf("Error saving session: %v", err)
}

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages