Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
N
nebula
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
exchain
nebula
Commits
096c5f20
Commit
096c5f20
authored
Jan 24, 2022
by
inphi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
proxyd: Allow cached RPC keys to be evicted
parent
d064eb8e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
1 deletion
+9
-1
curly-candles-pretend.md
.changeset/curly-candles-pretend.md
+5
-0
cache.go
go/proxyd/cache.go
+4
-1
No files found.
.changeset/curly-candles-pretend.md
0 → 100644
View file @
096c5f20
---
'
@eth-optimism/proxyd'
:
minor
---
proxyd: Allow cached RPCs to be evicted by redis
go/proxyd/cache.go
View file @
096c5f20
...
@@ -2,6 +2,7 @@ package proxyd
...
@@ -2,6 +2,7 @@ package proxyd
import
(
import
(
"context"
"context"
"time"
"github.com/go-redis/redis/v8"
"github.com/go-redis/redis/v8"
"github.com/golang/snappy"
"github.com/golang/snappy"
...
@@ -16,6 +17,8 @@ type Cache interface {
...
@@ -16,6 +17,8 @@ type Cache interface {
const
(
const
(
// assuming an average RPCRes size of 3 KB
// assuming an average RPCRes size of 3 KB
memoryCacheLimit
=
4096
memoryCacheLimit
=
4096
// Set a large ttl to avoid expirations. However, a ttl must be set for volatile-lru to take effect.
redisTTL
=
30
*
7
*
24
*
time
.
Hour
)
)
type
cache
struct
{
type
cache
struct
{
...
@@ -67,7 +70,7 @@ func (c *redisCache) Get(ctx context.Context, key string) (string, error) {
...
@@ -67,7 +70,7 @@ func (c *redisCache) Get(ctx context.Context, key string) (string, error) {
}
}
func
(
c
*
redisCache
)
Put
(
ctx
context
.
Context
,
key
string
,
value
string
)
error
{
func
(
c
*
redisCache
)
Put
(
ctx
context
.
Context
,
key
string
,
value
string
)
error
{
err
:=
c
.
rdb
.
Set
(
ctx
,
key
,
value
,
0
)
.
Err
()
err
:=
c
.
rdb
.
Set
EX
(
ctx
,
key
,
value
,
redisTTL
)
.
Err
()
if
err
!=
nil
{
if
err
!=
nil
{
RecordRedisError
(
"CacheSet"
)
RecordRedisError
(
"CacheSet"
)
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment