Local cache for PostgreSQL driver #3828

Closed
Tobotimus wants to merge 3 commits from Tobotimus/V3/feature/postgres_cache into V3/develop
Tobotimus commented 2020-05-07 10:01:13 +02:00 (Migrated from github.com)

Type

  • Enhancement

Description of the changes

I'm back! In some capacity at least...

I decided to whip up a cache for the Postgres driver. In theory this cache is generic and could be its own layer above all drivers, I didn't want to change anything about the JSON driver, and for now, Postgres is the only other one :)

The cache is an LRU cache, which scales up and down in size based on the number of cogs loaded (read: drivers instantiated). Its max size per cog is admittedly somewhat arbitrary and meaningless, considering the values stored in the cache could range from single bools to massive dicts. However I think it's better to get something working and process-efficient out there rather than get stuck on a cache-sizing issue, and this is still bound to be a lot more memory-efficient than the JSON driver.

I'm interested to hear what people's experiences are with regards to this, especially on large bots. I haven't actually done any performance testing, but anecdotally it seems a lot faster ;)

### Type - Enhancement ### Description of the changes I'm back! In some capacity at least... I decided to whip up a cache for the Postgres driver. In theory this cache is generic and could be its own layer above all drivers, I didn't want to change anything about the JSON driver, and for now, Postgres is the only other one :) The cache is an LRU cache, which scales up and down in size based on the number of cogs loaded (read: drivers instantiated). Its max size per cog is admittedly somewhat arbitrary and meaningless, considering the values stored in the cache could range from single bools to massive dicts. However I think it's better to get something working and process-efficient out there rather than get stuck on a cache-sizing issue, and this is still bound to be a lot more memory-efficient than the JSON driver. I'm interested to hear what people's experiences are with regards to this, especially on large bots. I haven't actually done any performance testing, but anecdotally it seems a lot faster ;)
tekulvw (Migrated from github.com) reviewed 2020-05-07 10:01:13 +02:00
Twentysix26 (Migrated from github.com) reviewed 2020-05-07 10:01:13 +02:00
Owner

Ich habe den PR geprüft und lasse ihn offen. Der Postgres-Treiber hat inzwischen Warnhinweise bekommen (#5975), und die Postgres-CI läuft jetzt auf Python 3.11–3.14 grün. Ein lokaler LRU-Cache bringt aber Konsistenzprobleme mit, sobald mehrere Prozesse dieselbe Datenbank nutzen oder Daten außerhalb des Bots geändert werden, und der Code ist von 2020 und konfligiert. Vor einem Merge sollte geklärt werden, ob der Cache optional (Opt-in) sein soll und wie er invalidiert wird.


Generated by Claude Code

Ich habe den PR geprüft und lasse ihn offen. Der Postgres-Treiber hat inzwischen Warnhinweise bekommen (#5975), und die Postgres-CI läuft jetzt auf Python 3.11–3.14 grün. Ein lokaler LRU-Cache bringt aber Konsistenzprobleme mit, sobald mehrere Prozesse dieselbe Datenbank nutzen oder Daten außerhalb des Bots geändert werden, und der Code ist von 2020 und konfligiert. Vor einem Merge sollte geklärt werden, ob der Cache optional (Opt-in) sein soll und wie er invalidiert wird. --- _Generated by [Claude Code](https://claude.ai/code)_
Owner

Auf Wunsch des Repo-Owners geschlossen; die Gründe stehen im Kommentar oben. Der PR kann jederzeit wieder geöffnet oder neu eingereicht werden.


Generated by Claude Code

Auf Wunsch des Repo-Owners geschlossen; die Gründe stehen im Kommentar oben. Der PR kann jederzeit wieder geöffnet oder neu eingereicht werden. --- _Generated by [Claude Code](https://claude.ai/code)_
Mrcoolgamer11 closed this pull request 2026-11-22 15:56:37 +01:00

Pull request closed

Sign in to join this conversation.
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 project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
Mrcoolgamer11/Red-DiscordBot!3828
No description provided.