cache

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jul 15, 2024 License: MIT Imports: 8 Imported by: 0

README

Cache Manager

A Go library for managing cache with Redis.

Installation

go get github.com/PrimaKu/cache

Setup

cacheManager, err := cache.NewCacheManager(redisOptions) // *redis.Options
if err != nil {
  log.Fatalf("Failed to start caching with: %v", err)
}

Get Cache

data := cacheManager.Get(context, "DATA_KEY")

Set Cache

err := cacheManager.Set(context, "DATA_KEY", "value to cache")

Delete Cache

err := cacheManager.Del(context, "DATA_KEY")

Documentation

Overview

Package cache is a generated GoMock package.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetValue

func GetValue[T any](ctx context.Context, cm CacheManager, key string) *T

Types

type CacheManager

type CacheManager interface {
	Get(ctx context.Context, key string) *string
	Set(ctx context.Context, key string, val any) error
	Del(ctx context.Context, key string) error
}

func NewCacheManager

func NewCacheManager(options *redis.Options) CacheManager

type MockCacheManager

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

MockCacheManager is a mock of CacheManager interface.

func NewMockCacheManager

func NewMockCacheManager(ctrl *gomock.Controller) *MockCacheManager

NewMockCacheManager creates a new mock instance.

func (*MockCacheManager) Del

func (m *MockCacheManager) Del(ctx context.Context, key string) error

Del mocks base method.

func (*MockCacheManager) EXPECT

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockCacheManager) Get

func (m *MockCacheManager) Get(ctx context.Context, key string) *string

Get mocks base method.

func (*MockCacheManager) Set

func (m *MockCacheManager) Set(ctx context.Context, key string, val any) error

Set mocks base method.

type MockCacheManagerMockRecorder

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

MockCacheManagerMockRecorder is the mock recorder for MockCacheManager.

func (*MockCacheManagerMockRecorder) Del

func (mr *MockCacheManagerMockRecorder) Del(ctx, key interface{}) *gomock.Call

Del indicates an expected call of Del.

func (*MockCacheManagerMockRecorder) Get

func (mr *MockCacheManagerMockRecorder) Get(ctx, key interface{}) *gomock.Call

Get indicates an expected call of Get.

func (*MockCacheManagerMockRecorder) Set

func (mr *MockCacheManagerMockRecorder) Set(ctx, key, val interface{}) *gomock.Call

Set indicates an expected call of Set.

Jump to

Keyboard shortcuts

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