All Projects → phachon → Fasthttpsession

phachon / Fasthttpsession

Licence: mit
A fast and powerful session package for fasthttp servers

Programming Languages

go
31211 projects - #10 most used programming language
golang
3204 projects

Projects that are alternatives of or similar to Fasthttpsession

laminas-session
Object-oriented interface to PHP sessions and storage
Stars: ✭ 35 (+84.21%)
Mutual labels:  session, sessionstorage
mst-persist
Persist and hydrate MobX-state-tree stores (in < 100 LoC)
Stars: ✭ 75 (+294.74%)
Mutual labels:  session, sessionstorage
Php Serialize
Use PHP's serialization methods from Ruby.
Stars: ✭ 119 (+526.32%)
Mutual labels:  session, sessionstorage
sessionx
Go's web session library.
Stars: ✭ 75 (+294.74%)
Mutual labels:  session, sessionstorage
Akka Http Session
Web & mobile client-side akka-http sessions, with optional JWT support
Stars: ✭ 429 (+2157.89%)
Mutual labels:  session
Redisson
Redisson - Redis Java client with features of In-Memory Data Grid. Over 50 Redis based Java objects and services: Set, Multimap, SortedSet, Map, List, Queue, Deque, Semaphore, Lock, AtomicLong, Map Reduce, Publish / Subscribe, Bloom filter, Spring Cache, Tomcat, Scheduler, JCache API, Hibernate, MyBatis, RPC, local cache ...
Stars: ✭ 17,972 (+94489.47%)
Mutual labels:  session
kemal-session
Simple session handler for Kemal
Stars: ✭ 47 (+147.37%)
Mutual labels:  session
visual-ts-game-engine
Typescript project based on matter.ts implementation."This version 2 of visualjs game engine, totally different approach. Whole project is based fully dependency build. Main file is app.ts and ioc.ts. Class ioc saves singleton instances also bind. In this project html and css is also present, webpack helps and handle this type of files. GamePlay…
Stars: ✭ 15 (-21.05%)
Mutual labels:  session
Storagedb
MongoDB-like API for HTML5 Storage (localStorage and sessionStorage)
Stars: ✭ 16 (-15.79%)
Mutual labels:  sessionstorage
Smart App Rate
An Android library that encourages users to rate the app on the Google Play.
Stars: ✭ 609 (+3105.26%)
Mutual labels:  session
Vim Workspace
📑 Automated Vim session management with file auto-save and persistent undo history
Stars: ✭ 374 (+1868.42%)
Mutual labels:  session
Jaguar
Jaguar, a server framework built for speed, simplicity and extensible. ORM, Session, Authentication & Authorization, OAuth
Stars: ✭ 286 (+1405.26%)
Mutual labels:  session
Vue Ls
💥 Vue plugin for work with local storage, session storage and memory storage from Vue context
Stars: ✭ 468 (+2363.16%)
Mutual labels:  sessionstorage
Immortaldb
🔩 A relentless key-value store for the browser.
Stars: ✭ 2,962 (+15489.47%)
Mutual labels:  sessionstorage
Session
Simple session middleware for Express
Stars: ✭ 5,571 (+29221.05%)
Mutual labels:  session
egg-session
session plugin for egg
Stars: ✭ 48 (+152.63%)
Mutual labels:  session
Pode
Pode is a Cross-Platform PowerShell web framework for creating REST APIs, Web Sites, and TCP/SMTP servers
Stars: ✭ 329 (+1631.58%)
Mutual labels:  session
Web Storage Cache
对localStorage 和sessionStorage 进行了扩展,添加了超时时间,序列化方法
Stars: ✭ 582 (+2963.16%)
Mutual labels:  sessionstorage
Koa Redis
Redis storage for Koa session middleware/cache with Sentinel and Cluster support
Stars: ✭ 324 (+1605.26%)
Mutual labels:  session
Angular Locker
🗄️ A simple & configurable abstraction for local/session storage in angular js projects
Stars: ✭ 318 (+1573.68%)
Mutual labels:  sessionstorage

logo

Sourcegraph build godoc license go_Report release powered_by platforms

fasthttpsession is a fast and powerful session package for fasthttp servers

中文文档

Description

fasthttpsession is a session manager for Go. It only supports fasthttp, currently support providers:

  • file
  • memcache
  • memory
  • mysql
  • postgres
  • redis
  • sqlite3

Features

  • Focus on the design of the code architecture and expansion.
  • Provide full session storage.
  • Convenient switching of session storage.
  • Customizable data serialization.
  • Implement concurrent map(ccmap.go) to improve performance.

Install

The only requirement is the Go Programming Language, at least v1.7

$ go get -u github.com/phachon/fasthttpsession
$ go get ./...

Used

Quick Start


// fasthttpsession use memory provider

import (
	"github.com/phachon/fasthttpsession"
	"github.com/phachon/fasthttpsession/memory"
	"github.com/valyala/fasthttp"
	"log"
	"os"
)

// default config
var session = fasthttpsession.NewSession(fasthttpsession.NewDefaultConfig())

func main()  {
	// you must set up provider before use
	err := session.SetProvider("memory", &memory.Config{})
	if err != nil {
		log.Println(err.Error())
		os.Exit(1)
	}
	addr := ":8086"
	log.Println("fasthttpsession example server listen: "+addr)
	
	// fasthttp start listen serve
	err = fasthttp.ListenAndServe(addr, requestHandle)
	if err != nil {
		log.Println("listen server error :"+err.Error())
	}
}

// request handler
func requestHandle(ctx *fasthttp.RequestCtx) {
	// start session
	sessionStore, err := session.Start(ctx)
	if err != nil {
		ctx.SetBodyString(err.Error())
		return
	}
	// must defer sessionStore.save(ctx)
	defer sessionStore.Save(ctx)

	sessionStore.Set("name", "fasthttpsession")

	ctx.SetBodyString(fmt.Sprintf("fasthttpsession setted key name= %s ok", sessionStore.Get("name").(string)))
}

Custom configuration

If you don't want to use the default configuration, please use the following struct custom.

type Config struct {

	// cookie name
	CookieName string
	
	// cookie domain
	Domain string
	
	// If you want to delete the cookie when the browser closes, set it to -1.
	//
	//  0 means no expire, (24 years)
	// -1 means when browser closes
	// >0 is the time.Duration which the session cookies should expire.
	Expires time.Duration
	
	// gc life time(s)
	GCLifetime int64
	
	// session life time(s)
	SessionLifetime int64
	
	// set whether to pass this bar cookie only through HTTPS
	Secure bool
	
	// sessionId is in url query
	SessionIdInURLQuery bool
	
	// sessionName in url query
	SessionNameInUrlQuery string
	
	// sessionId is in http header
	SessionIdInHttpHeader bool
	
	// sessionName in http header
	SessionNameInHttpHeader string
	
	// SessionIdGeneratorFunc should returns a random session id.
	SessionIdGeneratorFunc func() string
	
	// Encode the cookie value if not nil.
	EncodeFunc func(cookieValue string) (string, error)
	
	// Decode the cookie value if not nil.
	DecodeFunc func(cookieValue string) (string, error)
}

Different session provider config, please look at the Config.go the provider name directory.

Documents

Document address: http://godoc.org/github.com/phachon/fasthttpsession

Example

Some Example

Feedback

  • If you like the project, please Start.
  • If you have any problems in the process of use, welcome submit Issue.
  • If you find and solve bug, welcome submit Pull Request.
  • If you want to expand session provider, welcome Fork and merge this rep.
  • If you want to make a friend, welcome send email to [email protected].

License

MIT

Thanks

Create By [email protected]

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].