repocache

package module
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2024 License: Apache-2.0 Imports: 4 Imported by: 0

README

repo-cache

通用的对数据层缓存,特别是对数据库层的缓存

  • RepoCacheInterface

    • FindByID
    • Update
    • Create
    • Delete
  • StorageInterface

    • MemoryStorage

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type EntityModelInterface

type EntityModelInterface interface {
	GetID() ID
	Serialize() []byte //对象序列化
	Deserialize([]byte) (interface{}, error)
}

type ID

type ID string

type Limit

type Limit int64

type Order

type Order string

type Paginate

type Paginate[T EntityModelInterface] struct {
	Items []T   `json:"items"`
	Total int64 `json:"total"`
	Limit Limit `json:"limit"`
}

type PaginateID

type PaginateID struct {
	Items []ID  `json:"items"`
	Total int64 `json:"total"`
	Limit Limit `json:"limit"`
}

type RepoCache

type RepoCache[T EntityModelInterface] struct {
	// contains filtered or unexported fields
}

func (*RepoCache[T]) Create

func (it *RepoCache[T]) Create(ctx context.Context, m T) (T, error)

func (*RepoCache[T]) Delete

func (it *RepoCache[T]) Delete(ctx context.Context, id ID) error

func (*RepoCache[T]) Find

func (it *RepoCache[T]) Find(ctx context.Context, where Where) (Paginate[T], error)

func (*RepoCache[T]) FindByID

func (it *RepoCache[T]) FindByID(ctx context.Context, id ID) (T, error)

func (*RepoCache[T]) FindOne

func (it *RepoCache[T]) FindOne(ctx context.Context, where Where) (T, error)

func (*RepoCache[T]) Update

func (it *RepoCache[T]) Update(ctx context.Context, m T) (T, error)

type RepoCacheInterface

type RepoCacheInterface[T EntityModelInterface] interface {
	FindByID(context.Context, ID) (T, error)
	Update(context.Context, T) (T, error)
	Delete(context.Context, ID) error
	Create(context.Context, T) (T, error)
	Find(context.Context, Where) (Paginate[T], error)
	FindOne(context.Context, Where) (T, error)
}

type RepoInterface

type RepoInterface[T EntityModelInterface] interface {
	FindByID(context.Context, ID) (T, error)
	Update(context.Context, T) (T, error)
	Delete(context.Context, ID) error
	Create(context.Context, T) (T, error)
	Find(context.Context, Where) (PaginateID, error)
	FindOne(context.Context, Where) (ID, error)
}

type Where

type Where struct {
	SQL    string
	Args   []interface{}
	Limit  int64
	Offset int64
	Order  string
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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