Categorygithub.com/ahmetask/gocache/v2
modulepackage
2.1.1
Repository: https://github.com/ahmetask/gocache.git
Documentation: pkg.go.dev

# README

Gocache

Gocache is a Golang library for caching.

Installation

You need golang 1.13 to use gocache.

 go get github.com/ahmetask/gocache/v2

Example

Server

Client

Usage

package main

import (
	"fmt"
	"github.com/ahmetask/gocache/v2"
	"time"
)

func main() {
	cache := gocache.NewCache(5*time.Minute, 5*time.Second)

	cache.Set("foo", "bar", gocache.Eternal)
	cache.Set("foo2", 1, 5*time.Second)

	res, success := cache.Get("foo")
	fmt.Println(res)
	fmt.Println(success)
}


Cache Server Usage

package main

import (
	"github.com/ahmetask/gocache/v2"
	"time"
)

func main() {
	cache := gocache.NewCache(5*time.Minute, 5*time.Second)

	serverConfig := gocache.ServerConfig{
		CachePtr: cache,
		Port:     "8080",
	}

	gocache.NewCacheServer(serverConfig)
}

Cache Client Usage

package main

import (
	"github.com/ahmetask/gocache/v2"
)

func main() {
	request := gocache.AddCacheRequest{Key: "key", Value: "any interface", Life: 4}
	gocache.SaveCache("serviceIp", request)

	var r interface{}
	gocache.GetCache("serviceIp", "key", &r)
}


Worker Pool Usage

package main

import (
	"github.com/ahmetask/gocache/v2"
	"time"
)

func main()  {
	cache := gocache.NewCache(5*time.Minute, 5*time.Second)
	cache.StartWorkerPoolWith(2)
	
	cache.AddBackground("key", "value",  gocache.Eternal)
}

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

# Functions

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author

# Constants

constants for default cache life.

# Variables

No description provided by the author

# Structs

No description provided by the author
Cache properties.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
cached file content.
No description provided by the author
No description provided by the author
No description provided by the author
UnimplementedCacheServiceServer can be embedded to have forward compatible implementations.

# Interfaces

CacheServiceClient is the client API for CacheService service.
CacheServiceServer is the server API for CacheService service.