cache

package module
v0.0.0-...-ccfed10 Latest Latest
Warning

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

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

README

in-memory-cache-go

Golang tool for storing data in the system RAM

My first experience as a development package for storing data of the in-memory-cache type

Example

package main

import (
  "fmt"
  "github.com/d1mpi/in-memory-cache-go"
)

func main() {
	newCache := cache.New()
	setErr := newCache.Set("Alina", 12)
	if setErr != nil {
		fmt.Println(err)
		return
	}

	userId, getErr := newCache.Get("Alina")
	if getErr != nil {
		fmt.Println(err)
		return
	} else {
		fmt.Println(userId)
	}

	delErr := newCache.Delete("Alina")
	if delErr != nil {
		fmt.Println(err)
		return
	}

	userId = newCache.Get("Alina")
	fmt.Println(userId)
}

Install

Use go get -u github.com/d1mpi/in-memory-cache-go

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache

type Cache interface {
	New()
}

type Data

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

func New

func New() Data

func (Data) Delete

func (cache Data) Delete(key string) error

func (Data) Get

func (cache Data) Get(key string) (interface{}, error)

func (Data) Set

func (cache Data) Set(key string, value interface{}) error

Jump to

Keyboard shortcuts

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