gorm

package module
v0.0.0-...-6d031c4 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2022 License: MIT Imports: 3 Imported by: 1

README

Gorm

A Gorm storage driver for gorm database lib.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ConfigDefault = Config{
	Table:      "fiber_storage",
	Reset:      false,
	GCInterval: 10 * time.Second,
}

ConfigDefault is the default config

Functions

This section is empty.

Types

type Config

type Config struct {
	DB *gorm.DB

	// Table name
	//
	// Optional. Default is "fiber_storage"
	Table string

	// Reset clears any existing keys in existing Table
	//
	// Optional. Default is false
	Reset bool

	// Time before deleting expired keys
	//
	// Optional. Default is 10 * time.Second
	GCInterval time.Duration
}

Config defines the config for storage.

type Session

type Session struct {
	K string `gorm:"primaryKey"`
	V string `gorm:"type:blob"`
	E int64  `gorm:"default:0"`
}

func (Session) TableName

func (Session) TableName() string

type Storage

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

Storage interface that is implemented by storage providers

func New

func New(config ...Config) *Storage

New creates a new storage

func (*Storage) Close

func (s *Storage) Close() error

Close the database

func (*Storage) Delete

func (s *Storage) Delete(key string) error

Delete key by key

func (*Storage) Get

func (s *Storage) Get(key string) ([]byte, error)

Get value by key

func (*Storage) Reset

func (s *Storage) Reset() error

Reset all keys

func (*Storage) Set

func (s *Storage) Set(key string, val []byte, exp time.Duration) error

Set key with value Set key with value

Jump to

Keyboard shortcuts

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