1 Star 0 Fork 0

OSCHINA-MIRROR/tonysilver-micache

Join Gitlife
Discover and participate in excellent open source projects with over 10 million developers. Private repositories are also completely free :)
Join for free
Clone/Download
Contribute code
Sync code
Cancel
Hint: Since Git does not support empty folders, creating a folder will generate an empty .keep file.
Loading...
README.md

Micache: мини-кэш файлов на Go

Получение micache

$ go get gitee.com/migopher/micache

Установка пути к файлу кэша

package main

import "gitee.com/migopher/micache"

func main() {
	// устанавливаем путь к файлу кэша cache/
	micache.Dir = "cache/"
}

Настройка кэша и времени

package main

import "gitee.com/migopher/micache"

func main() {
	// задаём время истечения срока действия ключа 3600 секунд или 0 для постоянного сохранения
	micache.Set("go", "golang", 3600)
}

Извлечение кэша

package main

import (
	"fmt"
	"gitee.com/migopher/micache"
)

func main() {
	// извлекаем значение ключа из кэша
	v := micache.Get("go")
	fmt.Println(v)
}

Использование структуры

package main

import (
	"fmt"
	"gitee.com/migopher/micache"
)

type User struct {
	Uid      int
	UserName string
}

func main() {
	getUser := User{}
	micache.GetDecoding("go", &getUser)
	fmt.Println(getUser)
}

Проверка существования ключа

package main

import (
	"fmt"
	"gitee.com/migopher/micache"
)

func main() {
	b := micache.IsExist("go")
	fmt.Println(b)
}

Удаление ключа

package main

import (
	"fmt"
	"gitee.com/migopher/micache"
)

func main() {
	b := micache.Delete("go")
	fmt.Println(b)
}

Comments ( 0 )

You can comment after Login

Introduction

Пакет мини-кэша файлов в Golang. Expand Collapse
MIT
Cancel

Releases (1)

All

Contributor

All

Recent Activities

Load more
No more results to load
1
https://gitlife.ru/oschina-mirror/tonysilver-micache.git
git@gitlife.ru:oschina-mirror/tonysilver-micache.git
oschina-mirror
tonysilver-micache
tonysilver-micache
master