Skip to content

Latest commit

 

History

History
53 lines (38 loc) · 882 Bytes

README.md

File metadata and controls

53 lines (38 loc) · 882 Bytes

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)