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

Add redis wrappers & sub config support #6

Merged
merged 12 commits into from
Sep 12, 2022
Merged

Conversation

JamesReate
Copy link
Member

@JamesReate JamesReate commented Sep 7, 2022

Proposed changes

  • Add redis wrappers that we're using in a different projects so as to help standardize and reduce copy paste code etc. Note that we have a prefix property to optionally prefix keys due to sharing redis cluster with different projects, since the DB number option is not supported in redis cluster mode.

  • allow sub settings configuration in config loader. I know there is a way to make this infinitely hierarchical but idk if that is something we should allow, nor did i want to spend the time doing that / testing it.

@JamesReate JamesReate changed the title Add elastic and redis wrappers Add redis wrappers & sub config support Sep 10, 2022
config_loader_test.go Outdated Show resolved Hide resolved
TLSConfig: tlsConfig,
})
// cluster client does not have setting for DB, so must set it manually.
cc.Do(context.Background(), fmt.Sprintf("SELECT %d", redisSettings.DB))
Copy link
Member

@elffjs elffjs Sep 11, 2022

Choose a reason for hiding this comment

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

Does this call succeed? From the docs:

When using Redis Cluster, the SELECT command cannot be used, since Redis Cluster only supports database zero.

I wonder if we're just putting everything in the same database without knowing it.

Copy link
Member Author

Choose a reason for hiding this comment

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

yeah good find. no idea will have to look.

Copy link
Member Author

Choose a reason for hiding this comment

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

gonna remove that and leave a comment. I had only tested in local and dev.

Copy link
Member

@elffjs elffjs Sep 11, 2022

Choose a reason for hiding this comment

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

It could be dangerous to have this isolation work in dev and not prod.

You could pass in a prefix to use for all the keys, does that help at all?

Copy link
Member Author

Choose a reason for hiding this comment

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

hmm yeah, I was wondering how safe this would be, and yeah that is probably what we want to do. Also for administrative stuff, like finding all the keys for a specific service would be easier with a prepend search eg. KEYS dbNumb_* or for big sets SCAN 0 COUNT 50 MATCH dbNum_*

@JamesReate JamesReate merged commit 54355d0 into main Sep 12, 2022
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