cache

package module
v0.0.0-...-7a96563 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 7, 2022 License: MIT Imports: 0 Imported by: 0

README

In-memory cache go

Simple implementation of in-memory cache in Go

Implements a package with 4 methods:

  • NewCache() - creates a new cache object
  • Set() - value entry to cache by key
  • Get() - getting value by key
  • Delete() - deleting value by key
Instalation
go get github.com/aleksiumish/in-memory-cache
Example #1
Creating new cache object
package main

import (
	"fmt"
	"github.com/aleksiumish/in-memory-cache"
)
func main() {
	cache := cache.NewCache()
	fmt.Println("new cache object ", cache)
}
Example #2
1. Value entry to cache by key
2. Getting value
3. Delliting value
import (
	"fmt"
	"github.com/aleksiumish/in-memory-cache"
)
func main() {
	
	// value entry to cache by key
	cache := cache.NewCache()
	cache.Set("userId", 234234)
	
	// Getting value
	userId := cache.Get("userId") 
	
	// Deleting value by key
	cache.Delete("userId")
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache

type Cache struct {
	// contains filtered or unexported fields
}

func NewCache

func NewCache() *Cache

func (*Cache) Delete

func (c *Cache) Delete(key string)

func (*Cache) Get

func (c *Cache) Get(key string) interface{}

func (*Cache) Set

func (c *Cache) Set(key string, value interface{})

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL