1
0
mirror of https://github.com/go-micro/go-micro.git synced 2025-11-23 21:44:41 +02:00

fix: some linting issues (#2563)

This commit is contained in:
David Brouwer
2022-09-30 16:27:07 +02:00
committed by GitHub
parent 47e6a8d725
commit 85c0b0b8eb
221 changed files with 1025 additions and 1283 deletions

View File

@@ -11,29 +11,29 @@ import (
"go-micro.dev/v4/metadata"
)
// NewCache returns an initialised cache.
// NewCache returns an initialized cache.
func NewCache() *Cache {
return &Cache{
cache: cache.New(cache.NoExpiration, 30*time.Second),
}
}
// Cache for responses
// Cache for responses.
type Cache struct {
cache *cache.Cache
}
// Get a response from the cache
// Get a response from the cache.
func (c *Cache) Get(ctx context.Context, req *Request) (interface{}, bool) {
return c.cache.Get(key(ctx, req))
}
// Set a response in the cache
// Set a response in the cache.
func (c *Cache) Set(ctx context.Context, req *Request, rsp interface{}, expiry time.Duration) {
c.cache.Set(key(ctx, req), rsp, expiry)
}
// List the key value pairs in the cache
// List the key value pairs in the cache.
func (c *Cache) List() map[string]string {
items := c.cache.Items()
@@ -46,7 +46,7 @@ func (c *Cache) List() map[string]string {
return rsp
}
// key returns a hash for the context and request
// key returns a hash for the context and request.
func key(ctx context.Context, req *Request) string {
ns, _ := metadata.Get(ctx, "Micro-Namespace")