Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
C
cache
Manage
Activity
Members
Labels
Plan
Issues
2
Issue boards
Milestones
Wiki
Code
Merge requests
1
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Gaia-X
Trust Services API
cache
Commits
0244a381
Commit
0244a381
authored
2 years ago
by
Yordan Kinkov
Browse files
Options
Downloads
Patches
Plain Diff
#3
change GET endpoint response type to json
parent
9c3207f6
No related branches found
No related tags found
1 merge request
!3
Create SET cache endpoint
Pipeline
#49805
passed with stage
in 43 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
design/design.go
+2
-2
2 additions, 2 deletions
design/design.go
internal/clients/redis/client.go
+2
-2
2 additions, 2 deletions
internal/clients/redis/client.go
internal/service/cache/service.go
+2
-2
2 additions, 2 deletions
internal/service/cache/service.go
with
6 additions
and
6 deletions
design/design.go
+
2
−
2
View file @
0244a381
...
...
@@ -41,10 +41,10 @@ var _ = Service("cache", func() {
Description
(
"Cache service allows storing and retrieving data from distributed cache."
)
Method
(
"Get"
,
func
()
{
Description
(
"Get value from the cache.
The result is a sequence of bytes which the client must decode.
"
)
Description
(
"Get
JSON
value from the cache."
)
Payload
(
CacheGetRequest
)
Result
(
Bytes
)
Result
(
Any
)
HTTP
(
func
()
{
GET
(
"/v1/cache"
)
...
...
This diff is collapsed.
Click to expand it.
internal/clients/redis/client.go
+
2
−
2
View file @
0244a381
...
...
@@ -31,7 +31,7 @@ func New(addr, user, pass string, db int, defaultTTL time.Duration) *Client {
}
}
func
(
c
*
Client
)
Get
(
ctx
context
.
Context
,
key
string
)
(
[]
byte
,
error
)
{
func
(
c
*
Client
)
Get
(
ctx
context
.
Context
,
key
string
)
(
interface
{}
,
error
)
{
result
:=
c
.
rdb
.
Get
(
ctx
,
key
)
if
result
.
Err
()
!=
nil
{
if
result
.
Err
()
==
redis
.
Nil
{
...
...
@@ -39,7 +39,7 @@ func (c *Client) Get(ctx context.Context, key string) ([]byte, error) {
}
return
nil
,
result
.
Err
()
}
return
[]
byte
(
result
.
Val
()
)
,
nil
return
result
.
Val
(),
nil
}
func
(
c
*
Client
)
Set
(
ctx
context
.
Context
,
key
string
,
value
[]
byte
,
ttl
time
.
Duration
)
error
{
...
...
This diff is collapsed.
Click to expand it.
internal/service/cache/service.go
+
2
−
2
View file @
0244a381
...
...
@@ -13,7 +13,7 @@ import (
)
type
Cache
interface
{
Get
(
ctx
context
.
Context
,
key
string
)
(
[]
byte
,
error
)
Get
(
ctx
context
.
Context
,
key
string
)
(
interface
{}
,
error
)
Set
(
ctx
context
.
Context
,
key
string
,
value
[]
byte
,
ttl
time
.
Duration
)
error
}
...
...
@@ -29,7 +29,7 @@ func New(cache Cache, logger *zap.Logger) *Service {
}
}
func
(
s
*
Service
)
Get
(
ctx
context
.
Context
,
req
*
cache
.
CacheGetRequest
)
(
[]
byte
,
error
)
{
func
(
s
*
Service
)
Get
(
ctx
context
.
Context
,
req
*
cache
.
CacheGetRequest
)
(
interface
{}
,
error
)
{
var
operation
=
zap
.
String
(
"operation"
,
"get"
)
if
req
.
Key
==
""
||
req
.
Namespace
==
""
||
req
.
Scope
==
""
{
s
.
logger
.
Error
(
"bad request: missing key or namespace or scopes"
,
operation
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment