[Drivers] Add support for a Redis Driver #3762
No reviewers
Labels
No labels
Automated PR
Blocked
Blocked By: Damage Control
Blocked By: Dependency
Blocked By: Other PR
Breaking Change
Category: CI
Category: Cogs - Admin
Category: Cogs - Alias
Category: Cogs - Audio
Category: Cogs - Bank
Category: Cogs - Cleanup
Category: Cogs - CustomCommands
Category: Cogs - Dev
Category: Cogs - Downloader
Category: Cogs - Economy
Category: Cogs - Filter
Category: Cogs - General
Category: Cogs - Image
Category: Cogs - Mod
Category: Cogs - Modlog
Category: Cogs - Mutes
Category: Cogs - Permissions
Category: Cogs - Reports
Category: Cogs - Streams
Category: Cogs - Trivia
Category: Cogs - Trivia - Lists
Category: Cogs - Warnings
Category: Core - API - App Commands Package
Category: Core - API - Audio
Category: Core - API - Bank
Category: Core - API - Commands Package
Category: Core - API - Config
Category: Core - API - Other
Category: Core - API - Utils Package
Category: Core - Bot Class
Category: Core - Bot Commands
Category: Core - Command-line Interfaces
Category: Core - Downloader
Category: Core - Help
Category: Core - i18n
Category: Core - Modlog
Category: Core - Other Internals
Category: Core - RPC/ZMQ
Category: Docker
Category: Docs - Changelogs
Category: Docs - For Developers
Category: Docs - Install Guides
Category: Docs - Other
Category: Docs - User Guides
Category: Meta
Category: RPC/ZMQ methods
Category: Vendored Packages
Changelog Entry: Added
Changelog Entry: Pending
Changelog Entry: Skipped
Closed: Duplicate
Closed: External
Closed: Invalid
Closed: User Error
Closed: Won't Fix
Complex Issue
Docs-only
Feature Branch
Good First Issue
Help Wanted
High Priority
Needs Backport To stable-docs
No Activity
No Repro
QA: Bypassed
QA: Changes Requested
QA: Passed
Release Blocker
Status: Accepted
Status: Frozen
Status: In Progress
Status: Needs Discussion
Status: Needs Info
Status: Needs Triage
Status: PRs Welcome
Type: Bug
Type: Dependency Update
Type: Deprecation
Type: Enhancement
Type: Feature
Type: Informational
Type: Merge
Type: Optimisation
Type: Question
Type: Removal
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
Mrcoolgamer11/Red-DiscordBot!3762
Loading…
Reference in a new issue
No description provided.
Delete branch "redis"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Add the Redis Driver.
NOTE: THIS WILL NOT WORK with a simple Redis driver, You will need the ReJSON plugin enabled in the Redis server.
More instructions can be found in https://rejson.io/
If you want a simple Docker image with it already built and enable use
redislabs/redisjson2:latestotherwise to do it manually follow https://oss.redislabs.com/redisjson/#building-and-loading-the-moduleWARNING: If you are doing this you need to ensure your redis server is persisting data, otherwise all your data will be wiped in a system restart.
Setup
Hosting the server with Docker
docker-compose.yamlCreate a file:
<full path to redis storage>\redis.confand paste the content of this https://gist.github.com/Drapersniper/b119bf588c0890af75659373579568e2 config inside of itBy default the password for the server is
foorbarredTo edit the password open
redis.confand edit the following line:requirepass foorbarredtorequirepass <my new password>Start the reJSON server:
cdinto the folder where you saved thedocker-compose.yamland rundocker-compose up -dMigrate from JSON to Redis
run :
redbot-setup convert <instance_name> redisFollow the prompts to connecto to your redis server. (Note the IP for the redis server will be
172.27.0.2)Once migration is completed start the bot
Edit 21/09/20
Note:
add this to the end of your
redis.conffile you've downloaded, if you wish to setup the redis server with UNIX sockets.I removed the "Blocked by: Other PR" label as #3714 is merged already but this PR now needs conflict resolution.
Primary requirements need to be added to
tools/primary_deps.iniThis is missing
aioredis_lock(though it seems like you're not using it at all)Info about the
redisextra needs to be added to install_windows, install_linux_mac, and update_red documents in docs.If you need help with setting up tests/CI, here's a commit adding those for redis, feel free to use it if you want to (fully working, CI fails only because you didn't add
aioredis_locktoredisextra):github.com/jack1142/Red-DiscordBot@4b9f2d4685Could we get redis tests done in CI on this PR? So we can easily track how it's going passing tests and such
Jack has a commit for it somewhere I been sorta busy with other stuff but I'll add test prior to it being fully reviewed
I fixed the stuff I mentioned in my review comments and added tox env for Redis and job in CI workflow.
Small reminder that when this gets merged,
Tests / Tox - Redis (3.8) (pull_request)needs to be made a required check.This PR in it of itself isn't breaking end users directly, but as discussed in discord, there needs to be some restrictions on config stored values, a breaking window, and tools for cog creators.
Limits needed by this PR:
64-bit integer limits and disallowing
NaNandinf(positive and negative of each) in floats.Further limit which should really be fine and may allow other improvements in the future from one set of restrictions, but that I don't think is strictly enforced currently: utf-8 strings. (all messages from discord are utf-8, python source code is utf-8, you have to go out of your way to get something else here)
This is probably going to need an issue and discussion of how to handle this separately.
While a 53 bit integer limit would maximize the potential for future library use, given that discord IDs are 64bit, this seems like a limit that can't be used without massive impact which is not worth the potential gains.
Posting this here so it doesn't get lost:

Currently there is an issue with the Redis driver, which is basically that a cog named
Space(maybe other names too?) will not register the data, but only an empty dict.Here is a screenshot of the issue in action:
Can confirm Redis works well.
Here is a systemd snippet which you have to modify incase you want Red to wait for redis. redis-cli is required on the server.
Months after using this I can confirm this is super smooth and made my bot much faster and allows me to code less efficient now cause config will take the load.
Made the change to using this for my hosted Red.
Truly night and day difference in pretty well every aspect as far as response time, and performance re: system and connectivity. The provided walkthru was followed and on completing was success. A few things to note in the documentation would be validating updated installs of docker/docker-compose and defining your own paths for the docker-compose.yaml file to launch your container.
Dope PR
I have tested this for over a week and had zero issues with it. It took some figuring out for proper wait for redis initialization in systemd but we figured it out here is an example of what worked for me.
Technically speaking I couldn't see any real difference between this and previously used json driver. However, anecdotally I have noticed that there's a slight latency when using this compared to the json driver. That's not to say there isn't a need for this in some situations and that we should be eeking out the maximum performance latencies from our bots but it is just an observation I wanted to make note of here since I will be switching back to json driver for the time being.
While trying to backup my instance using
redbot-setup backup, I got the following error:Pull request closed