Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[RedisCache] For RateLimiting #77

Closed
wants to merge 8 commits into from
Closed

[RedisCache] For RateLimiting #77

wants to merge 8 commits into from

Conversation

siddimore
Copy link
Contributor

@siddimore siddimore commented Nov 26, 2023

Why are these changes needed?

Introduce RedisStore instead of dynamoDB for storing RateLimiting Params

Changes

  1. Implement RedisClient
  2. Implement RedisStore for common.KVStore
  3. Add DataFlags for RedisCache

Checks

  • I've made sure the lint is passing in this PR.
  • I've made sure the tests are passing. Note that there might be a few flaky tests, in that case, please comment that they are not relevant.
  • Testing Strategy
    • Unit tests
    • Integration tests
    • This PR is not tested :(

@siddimore siddimore requested a review from ian-shim November 28, 2023 16:24
@siddimore siddimore marked this pull request as ready for review November 29, 2023 05:54
@siddimore siddimore changed the title [RedisStore]For RateLimiting [RedisCache] For RateLimiting Nov 29, 2023
Copy link
Contributor

@wmb-software-consulting wmb-software-consulting left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should create a fork instead of directly opening a PR

client *commoncache.RedisClient
}

func NewRedisStore[T any](client *commoncache.RedisClient) common.KVStore[T] {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

client Should be an interface and not implementation

)

type RedisStore[T any] struct {
client *commoncache.RedisClient
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be an interface and not implementation

return err
}

return s.client.Set(ctx, key, jsonData, 0).Err() // 0 means no expiration
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if we want do add expiration? What do you think of adding it as params?

"time"

"github.com/Layr-Labs/eigenda/common"
"github.com/go-redis/redis/v8"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

client *commoncache.RedisClient
}

func NewRedisStore[T any](client *commoncache.RedisClient) common.KVStore[T] {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Preferable to return pointer struct instead of interface by convention
*RedisStore[T]

type RedisStore[T any] struct {
client *commoncache.RedisClient
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add this interface static checker.
var _ common.KVStore[any] = (*RedisStore[any])(nil)

@siddimore siddimore closed this Dec 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants