package
0.0.0-20180601060148-d032931de3c3
Repository: https://github.com/cloudwise-opensource/gocrab.git
Documentation: pkg.go.dev

# README

cache

cache is a Go cache manager. It can use many cache adapters. The repo is inspired by database/sql .

How to install?

go get github.com/CloudWise-OpenSource/GoCrab/Core/cache

What adapters are supported?

As of now this cache support memory, Memcache and Redis.

How to use it?

First you must import it

import (
	"github.com/CloudWise-OpenSource/GoCrab/Core/cache"
)

Then init a Cache (example with memory adapter)

bm, err := cache.NewCache("memory", `{"interval":60}`)	

Use it like this:

bm.Put("Neeke", 1, 10)
bm.Get("Neeke")
bm.IsExist("Neeke")
bm.Delete("Neeke")

Memory adapter

Configure memory adapter like this:

{"interval":60}

interval means the gc time. The cache will check at each time interval, whether item has expired.

Memcache adapter

Memcache adapter use the vitess's Memcache client.

Configure like this:

{"conn":"127.0.0.1:11211"}

Redis adapter

Redis adapter use the redigo client.

Configure like this:

{"conn":":6039"}

# Packages

Package memcache provides a client for the memcached cache server.
package redis for cache provider depend on github.com/garyburd/redigo/redis go install github.com/garyburd/redigo/redis Usage: import( _ "github.com/CloudWise-OpenSource/GoCrab/Core/cache/redis" "github.com/CloudWise-OpenSource/GoCrab/Core/cache" ) bm, err := cache.NewCache("redis", `{"conn":"127.0.0.1:11211"}`) .

# Functions

Get bytes to file.
Put bytes to file.
convert interface to bool.
convert interface to float64.
convert interface to int.
convert interface to int64.
convert interface to string.
Gob decodes file cache item.
Gob encodes file cache item.
Create a new cache driver by adapter name and config string.
Create new file cache with no config.
NewMemoryCache returns a new MemoryCache.
Register makes a cache adapter available by the adapter name.

# Variables

1 minute.
cache file deep level if auto generated cache files.
cache expire time, default is no expire forever.
cache file suffix.
cache directory.

# Structs

FileCache is cache adapter for file storage.
FileCacheItem is basic unit of file cache adapter.
Memory cache adapter.
Memory cache item.

# Interfaces

Cache interface contains all behaviors for cache adapter.