Skip to content

ponder2000/cache

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

cache

Go Reference Go Report Card License

cache is an in memory cache library to handle caches in the form of key value or FIFO style queue with expiration support. The main advantage is that we can have one timer to watch multiple cache objects this increases efficiency compared to patrickmn/go-cache when you need to have a large number of cache objects.

Installation

To install this package, use go get:

go get -u github.com/ponder2000/cache

Usage

package main

import (
	"fmt"
	"time"

	"github.com/ponder2000/cache"
)

func main() {
	// suppose you want to create one janitor for 100 cache where the janitors will clean all 100 caches expired item after 3 seconds
	numberOfCachePerJanitor := 100
	janitorCleanupSchedule := time.Second * 3
	janitorOption := cache.NewJanitorConfigOption(numberOfCachePerJanitor, janitorCleanupSchedule)
	janitorPool := cache.NewJanitorPool(janitorOption)

	// now keep creating cache object as much as you want and register it to the janitor pool
	for i := 0; i<1000; i++ {
		cache := cache.NewListCacher(time.Second * 1)
		janitorPool.RegisterCache(cache)
	}
	
	// note : in the above case janitor pool will have 10 janitor looking after 100 caches each
	
}

Documentation

For full package documentation, visit pkg.go.dev.

License

This project is licensed under the MIT License.

Acknowledgments

Inspired from patrickmn/go-cache

Contact

Feel free to reach out if you have any questions or feedback!

About

Go cache implementation with pool of janitor

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages