Skip to content

JaydeRussell/caching-test

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Cache

Develop a cache that supports TTL with an active strategy instead of a lazy strategy (or passive). You can read more about lazy vs active removing here.

  • The cache should support a string-like type as key and a byte slice as value.
  • The code must come with a benchmark (in order to check for the allocations).
  • You can't use a map or an external library. You must create your own data structure.
  • The cache functions can't produce more than 1 allocation per operation.
  • The cache supports active TTL

The cache should satisfy the following interface:

type Cache interface {
	// Set will store the key value pair with a given TTL.
	Set(key, value []byte, ttl time.Duration)

	// Get returns the value stored using `key`.
	//
	// If the key is not present value will be set to nil.
	Get(key []byte) (value []byte, ttl time.Duration)
}

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Contributors