valkstore

package module
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: May 27, 2025 License: MIT Imports: 8 Imported by: 0

README

valkstore

A session store provider for gorilla/sessions utilizing the valkey-go client.

Installation

go get github.com/jamesd4y/valkstore

Usage

Documentation available on pkg.go.dev.

Example
package main

// TODO implement me

Todo

  • Implement session storage backend for valkey-go
  • Add unit tests with valkey instance
  • Improve performance e.g. prefix string generation, de/serializing

License

This project is licensed under the MIT License - see the LICENSE file for details.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type JsonSerializer

type JsonSerializer struct{}

func (JsonSerializer) Marshal

func (s JsonSerializer) Marshal(session *sessions.Session) ([]byte, error)

func (JsonSerializer) Unmarshal

func (s JsonSerializer) Unmarshal(b []byte, session *sessions.Session) error

type Option

type Option func(*ValKStore)

func WithCodec

func WithCodec(codec securecookie.Codec) Option

func WithOptions added in v0.1.2

func WithOptions(options *sessions.Options) Option

func WithPrefix

func WithPrefix(prefix string) Option

func WithSerializer

func WithSerializer(serializer Serializer) Option

type Serializer

type Serializer interface {
	Marshal(*sessions.Session) ([]byte, error)
	Unmarshal([]byte, *sessions.Session) error
}

type ValKStore

type ValKStore struct {
	// contains filtered or unexported fields
}

ValKStore implements a gorilla/sessions store backed by a ValKey database Utilizing valkey-go under the hood for higher throughput compared to the go-redis driver

func NewValKStore

func NewValKStore(address, username, password string, options ...Option) (*ValKStore, error)

func NewValKStoreWithClientOption

func NewValKStoreWithClientOption(option valkey.ClientOption, options ...Option) (*ValKStore, error)

func (*ValKStore) Close

func (v *ValKStore) Close()

func (*ValKStore) Get

func (v *ValKStore) Get(r *http.Request, name string) (*sessions.Session, error)

func (*ValKStore) New

func (v *ValKStore) New(r *http.Request, name string) (*sessions.Session, error)

func (*ValKStore) Save

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

Jump to

Keyboard shortcuts

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