1
0
mirror of https://github.com/go-micro/go-micro.git synced 2024-11-30 08:06:40 +02:00
go-micro/examples/cache
Asim Aslam 62801c3d68 update
2021-10-13 13:31:23 +01:00
..
handler update 2021-10-13 13:31:23 +01:00
proto go-micro.dev/v4 (#2305) 2021-10-12 12:55:53 +01:00
main.go update 2021-10-13 13:31:23 +01:00
README.md Add cache example (#2232) 2021-09-01 10:08:43 +01:00

Cache

This is an example of a cache service using the asim/go-micro/cache package.

Contents

This project was generated using Gomu.

  • handler - contains the service handler
  • proto - contains the protocol buffer and generated code

Usage

Run the go.micro.srv.cache service using Gomu.

gomu run

You can also run it using plain Go.

go run main.go

We'll be using Gomu to call the service. You can store a new key-value pair in the cache.

gomu call go.micro.srv.cache Cache.Put '{"key":"test","value":"hello go-micro","duration":"12h"}'

You can get values from the cache.

$ gomu call go.micro.srv.cache Cache.Get '{"key":"test"}'
{"expiration":"2021-09-01 22:42:24.2370591 +0200 CEST","value":"hello go-micro"}

Finally you can delete keys from the cache.

gomu call go.micro.srv.cache Cache.Delete '{"key":"test"}'