Skip to content

lysyi-dev/cache

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Cache package

This is a test package

Here, I practiced with concepts such as:

  • structures
  • empty interface
  • maps
  • working with a single object (passing by reference)
  • modules
  • tests

Here is the translated text for the method descriptions:

  • c.Get - adds a value to the cache
  • c.Set - retrieves a value by key
  • c.Delete - deletes a value by key
  • c.Clear - clears the entire cache

Usage Example

package main

import (
	"fmt"
	cache "github.com/lysyi-dev/cache"
)

func main() {
	c := cache.New()

	// Add a value to the cache
	c.Set("some_key", "some_value")

	// Retrieve a value by key
	if val, ok := c.Get("some_key"); ok {
		fmt.Println("Found:", val)
	} else {
		fmt.Println("Not ok")
	}

	// Delete a value by key
	c.Delete("some_key")
	if val, ok := c.Get("some_key"); ok {
		fmt.Println("Found:", val)
	} else {
		fmt.Println("Not ok")
	}

	// Clear the entire cache
	c.Set("some_key_2", "some_value_2")
	c.Clear()
	if _, ok := c.Get("some_key_2"); !ok {
		fmt.Println("Cache cleared")
	}
}

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages