cache

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 23, 2026 License: MIT Imports: 11 Imported by: 0

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