Skip to content

Basic cache in go It's an example of how to use basic cache using Go

Notifications You must be signed in to change notification settings

bypepe77/basic_cache_in_go

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Basic cache in Go

Basic cache in go It's an example of how to use basic cache using Go

Installation

go get github.com/bypepe77/basic_cache_in_go

How to run it?

 go run cmd/main.go

Models

 // Todo Model
type Todo struct {
	ID       uuid.UUID
	Content  string
	Finished bool
}

How to use it

todoCtrl := todo.NewTodoController()

todo := todoCtrl.AddNewTodo()

// Find todo(first call will not be cached)
todoNotCached, err := todoCtrl.GetTodoById(todo.ID)
if err != nil {
     fmt.Println("Error getting todo", err)
}
fmt.Println("todo not cached", todoNotCached)

// Find todo(cached)
todoCached, err := todoCtrl.GetTodoById(todo.ID)
if err != nil {
     fmt.Println("Error getting todo", err)
}
fmt.Println("todo cached", todoCached)

About

Basic cache in go It's an example of how to use basic cache using Go

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages