1
0
mirror of https://github.com/go-micro/go-micro.git synced 2024-12-18 08:26:38 +02:00
go-micro/registry/cache
littlecoderonway 4d5b3b084f
Fix registry cache broken (#2715)
* services is shared between routines, when application change services returned by get function may lead to other routine set a changed services to cache

* services is shared between routines, when application change services returned by get function may lead to other routine set a changed services to cache

---------

Co-authored-by: Shuaihu Liu <shuaihu.liu@shopee.com>
2024-07-02 09:30:51 +01:00
..
cache.go Fix registry cache broken (#2715) 2024-07-02 09:30:51 +01:00
options.go v5 2024-06-04 21:40:43 +01:00
README.md fix: linting issues (#2566) 2022-09-30 20:32:55 +02:00

Registry Cache

Cache is a library that provides a caching layer for the go-micro registry.

If you're looking for caching in your microservices use the selector.

Interface

// Cache is the registry cache interface
type Cache interface {
	// embed the registry interface
	registry.Registry
	// stop the cache watcher
	Stop()
}

Usage

import (
	"github.com/micro/go-micro/registry"
	"github.com/micro/go-micro/registry/cache"
)

r := registry.NewRegistry()
cache := cache.New(r)

services, _ := cache.GetService("my.service")