cache

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Jul 24, 2026 License: MIT Imports: 11 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CacheServiceProvider

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

func (*CacheServiceProvider) Boot

func (*CacheServiceProvider) Conf

func (p *CacheServiceProvider) Conf() map[string]string

func (*CacheServiceProvider) Description

func (p *CacheServiceProvider) Description() string

func (*CacheServiceProvider) Register

func (p *CacheServiceProvider) Register(ctx context.Context) error

func (*CacheServiceProvider) SetApplication

func (p *CacheServiceProvider) SetApplication(app foundation.Application)

type MemoryCache

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

MemoryCache 进程内缓存(L1 默认实现)。

func NewMemoryCache

func NewMemoryCache() *MemoryCache

func (*MemoryCache) Delete

func (c *MemoryCache) Delete(ctx context.Context, key string) error

func (*MemoryCache) Get

func (c *MemoryCache) Get(ctx context.Context, key string) ([]byte, error)

func (*MemoryCache) GetString

func (c *MemoryCache) GetString(ctx context.Context, key string) (string, error)

func (*MemoryCache) Has

func (c *MemoryCache) Has(ctx context.Context, key string) (bool, error)

func (*MemoryCache) Set

func (c *MemoryCache) Set(ctx context.Context, key string, value []byte, ttl time.Duration) error

func (*MemoryCache) SetString

func (c *MemoryCache) SetString(ctx context.Context, key string, value string, ttl time.Duration) error

type Options

type Options struct {
	Driver string `json:"driver"` // memory | redis
	Prefix string `json:"prefix"`
}

type RedisCache

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

RedisCache 基于 Redis 的缓存实现(L2,依赖 redis Provider)。

func NewRedisCache

func NewRedisCache(client redis.UniversalClient, prefix string) *RedisCache

func (*RedisCache) Delete

func (c *RedisCache) Delete(ctx context.Context, key string) error

func (*RedisCache) Get

func (c *RedisCache) Get(ctx context.Context, key string) ([]byte, error)

func (*RedisCache) Has

func (c *RedisCache) Has(ctx context.Context, key string) (bool, error)

func (*RedisCache) Set

func (c *RedisCache) Set(ctx context.Context, key string, value []byte, ttl time.Duration) error

Source Files

  • cache_service_provider.go
  • memory.go
  • redis.go

Jump to

Keyboard shortcuts

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