All Projects → antonlindstrom → Pgstore

antonlindstrom / Pgstore

Licence: mit
A Postgres session store backend for gorilla/sessions

Programming Languages

go
31211 projects - #10 most used programming language

Projects that are alternatives of or similar to Pgstore

sessionx
Go's web session library.
Stars: ✭ 75 (+13.64%)
Mutual labels:  sessions, sessionstorage
Connect Session Sequelize
Sequelize SessionStore for Express/Connect
Stars: ✭ 179 (+171.21%)
Mutual labels:  sessions, sessionstorage
Guardian auth
The Guardian Authentication Implementation Using Ecto/Postgresql Elixir Phoenix [ User Authentication ]
Stars: ✭ 15 (-77.27%)
Mutual labels:  postgres, sessions
Node Connect Pg Simple
A simple, minimal PostgreSQL session store for Connect/Express
Stars: ✭ 166 (+151.52%)
Mutual labels:  postgres, sessionstorage
Php Storageless Sessions
Sessions handler which stores session data in HMAC-signed and encrypted cookies
Stars: ✭ 29 (-56.06%)
Mutual labels:  sessions, sessionstorage
Postgresclientkit
A PostgreSQL client library for Swift. Does not require libpq.
Stars: ✭ 49 (-25.76%)
Mutual labels:  postgres
Django Tsvector Field
Django field for tsvector (PostgreSQL full text search vector) with managed stored procedure and triggers.
Stars: ✭ 56 (-15.15%)
Mutual labels:  postgres
Barman
Barman - Backup and Recovery Manager for PostgreSQL
Stars: ✭ 1,044 (+1481.82%)
Mutual labels:  postgres
Pgtools
Gui application to monitor postgres database events in real time
Stars: ✭ 42 (-36.36%)
Mutual labels:  postgres
Django Qsessions
Extended session backends for Django (Sessions store IP, User Agent, and foreign key to User)
Stars: ✭ 64 (-3.03%)
Mutual labels:  sessions
Skunk
A data access library for Scala + Postgres.
Stars: ✭ 1,107 (+1577.27%)
Mutual labels:  postgres
Ptgo
PostgreSQL Triggers in Go
Stars: ✭ 55 (-16.67%)
Mutual labels:  postgres
Ppx pgsql
Syntax extension for embedded SQL queries using PG'OCaml.
Stars: ✭ 50 (-24.24%)
Mutual labels:  postgres
Docker Backup Database
Docker image to periodically backup your database (MySQL, Postgres, or MongoDB) to S3 or local disk.
Stars: ✭ 57 (-13.64%)
Mutual labels:  postgres
Scala Db Codegen
Scala code/boilerplate generator from a db schema
Stars: ✭ 49 (-25.76%)
Mutual labels:  postgres
Rpg Boilerplate
Relay (React), Postgres, and Graphile (GraphQL): A Modern Frontend and API Boilerplate
Stars: ✭ 62 (-6.06%)
Mutual labels:  postgres
Pg variables
Session wide variables for PostgreSQL
Stars: ✭ 44 (-33.33%)
Mutual labels:  postgres
Fullstack Apollo Express Postgresql Boilerplate
💥 A sophisticated GraphQL with Apollo, Express and PostgreSQL boilerplate project.
Stars: ✭ 1,079 (+1534.85%)
Mutual labels:  postgres
Stackexchange Dump To Postgres
Python scripts to import StackExchange data dump into Postgres DB.
Stars: ✭ 58 (-12.12%)
Mutual labels:  postgres
Postgres.py
A nice PostgreSQL client library
Stars: ✭ 54 (-18.18%)
Mutual labels:  postgres

pgstore

A session store backend for gorilla/sessions - src.

Installation

make get-deps

Documentation

Available on godoc.org.

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

Example

package examples

import (
	"log"
	"net/http"
	"time"

	"github.com/antonlindstrom/pgstore"
)

// ExampleHandler is an example that displays the usage of PGStore.
func ExampleHandler(w http.ResponseWriter, r *http.Request) {
	// Fetch new store.
	store, err := pgstore.NewPGStore("postgres://user:[email protected]:5432/database?sslmode=verify-full", []byte("secret-key"))
	if err != nil {
		log.Fatalf(err.Error())
	}
	defer store.Close()

	// Run a background goroutine to clean up expired sessions from the database.
	defer store.StopCleanup(store.Cleanup(time.Minute * 5))

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

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

	// Save.
	if err = session.Save(r, w); err != nil {
		log.Fatalf("Error saving session: %v", err)
	}

	// Delete session.
	session.Options.MaxAge = -1
	if err = session.Save(r, w); err != nil {
		log.Fatalf("Error saving session: %v", err)
	}
}

Breaking changes

  • 2016-07-19 - NewPGStore and NewPGStoreFromPool now returns (*PGStore, error)

Thanks

I've stolen, borrowed and gotten inspiration from the other backends available:

Thank you all for sharing your code!

What makes this backend different is that it's for PostgreSQL.

We've recently refactored this backend to use the standard database/sql driver instead of Gorp. This removes a dependency and makes this package very lightweight and makes database interactions very transparent. Lastly, from the standpoint of unit testing where you want to mock the database layer instead of requiring a real database, you can now easily use a package like go-SQLMock to do just that.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].