gormcache

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: May 14, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewGormHashService

func NewGormHashService(db *gorm.DB, logger *zap.Logger) cache.Hash

func NewGormListService

func NewGormListService[T any](prefix string, dur time.Duration) cache.CachedList[T]

Types

type CacheEntry

type CacheEntry struct {
	ID        uint       `gorm:"primaryKey"`
	Key       string     `gorm:"size:255;uniqueIndex;not null"`
	Value     string     `gorm:"type:text"`
	ExpiresAt *time.Time `gorm:"index"`
	CreatedAt time.Time
	UpdatedAt time.Time
	DeletedAt gorm.DeletedAt `gorm:"index"`
}

type GormHashService

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

func (*GormHashService) Existed

func (gh *GormHashService) Existed(ctx context.Context, key string) (bool, error)

func (*GormHashService) GetAll

func (gh *GormHashService) GetAll(ctx context.Context, key string) (map[string]string, error)

func (*GormHashService) GetValues

func (gh *GormHashService) GetValues(ctx context.Context, key string, fields ...string) ([]any, error)

func (*GormHashService) SetTTL

func (gh *GormHashService) SetTTL(ctx context.Context, key string, ttl time.Duration)

func (*GormHashService) SetValues

func (gh *GormHashService) SetValues(ctx context.Context, key string, values map[string]any) error

type GormListService

type GormListService[T any] struct {
	// contains filtered or unexported fields
}

func (*GormListService[T]) Append

func (gl *GormListService[T]) Append(ctx context.Context, key string, raw ...T) error

func (*GormListService[T]) Del

func (gl *GormListService[T]) Del(ctx context.Context, key string) error

func (*GormListService[T]) GetAll

func (gl *GormListService[T]) GetAll(ctx context.Context, key string) ([]T, error)

type HashEntry

type HashEntry struct {
	ID        uint       `gorm:"primaryKey"`
	Key       string     `gorm:"size:255;index;not null"`
	Field     string     `gorm:"size:255;not null"`
	Value     string     `gorm:"type:text"`
	ExpiresAt *time.Time `gorm:"index"`
	CreatedAt time.Time
	UpdatedAt time.Time
	DeletedAt gorm.DeletedAt `gorm:"index"`
}

type ListEntry

type ListEntry struct {
	ID        uint       `gorm:"primaryKey"`
	Key       string     `gorm:"size:255;index;not null"`
	Value     string     `gorm:"type:text"`
	SortOrder int        `gorm:"index"`
	ExpiresAt *time.Time `gorm:"index"`
	CreatedAt time.Time
	UpdatedAt time.Time
	DeletedAt gorm.DeletedAt `gorm:"index"`
}

Jump to

Keyboard shortcuts

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