cache

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Aug 23, 2024 License: MIT Imports: 6 Imported by: 4

README

gFly Caching

Copyright © 2023, gFly
https://www.gFly.dev
All rights reserved.
Usage

Install

go get -u github.com/gflydev/cache@v1.0.0

Quick usage main.go

import (
    _ "github.com/gflydev/cache"
)

kv := cache.New()

// Set cache 15 days
if err = kv.Set(key, value, time.Duration(15*24*3600) * time.Second); err != nil {
    log.Errorf("Error %q", err)
}

val, err := kv.Get(key)
if err != nil {
    log.Errorf("Error %q", err)
}

// Delete 
if err = kv.Del(key); err != nil {
    log.Errorf("Error %q", err)
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Key

func Key(key string) string

Key wrapper key

Types

type ICache

type ICache interface {
	Set(key string, value interface{}, expiration time.Duration) error
	Get(key string) (interface{}, error)
	Del(key string) error
}

func New

func New() ICache

type RedisDriver

type RedisDriver struct{}

func (RedisDriver) Del

func (r RedisDriver) Del(key string) error

func (RedisDriver) Get

func (r RedisDriver) Get(key string) (interface{}, error)

func (RedisDriver) Set

func (r RedisDriver) Set(key string, value interface{}, expiration time.Duration) error

Jump to

Keyboard shortcuts

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