mirror of
https://github.com/kevin-DL/services.git
synced 2026-01-12 03:05:14 +00:00
add default value
This commit is contained in:
6
cache/handler/cache.go
vendored
6
cache/handler/cache.go
vendored
@@ -34,6 +34,11 @@ func (c *Cache) Get(ctx context.Context, req *pb.GetRequest, rsp *pb.GetResponse
|
||||
value = ""
|
||||
}
|
||||
|
||||
// set the default value if specified
|
||||
if value == nil && len(req.DefaultValue) > 0 {
|
||||
value = req.DefaultValue
|
||||
}
|
||||
|
||||
rsp.Key = req.Key
|
||||
// set the value
|
||||
rsp.Value = fmt.Sprintf("%v", value)
|
||||
@@ -44,6 +49,7 @@ func (c *Cache) Get(ctx context.Context, req *pb.GetRequest, rsp *pb.GetResponse
|
||||
rsp.Ttl = 0
|
||||
}
|
||||
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user