feat: add LRU bucket metadata cache to presigned-url-plugin#946
Merged
pyramation merged 1 commit intomainfrom Apr 1, 2026
Merged
feat: add LRU bucket metadata cache to presigned-url-plugin#946pyramation merged 1 commit intomainfrom
pyramation merged 1 commit intomainfrom
Conversation
- Add bucketCache LRU (max 500, same TTL as storage module cache)
- Composite key: bucket:${databaseId}:${bucketKey}
- getBucketConfig() checks cache first, falls back to DB query
- clearStorageModuleCache() now clears both caches (coordinated eviction)
- clearBucketCache() for per-database eviction
- plugin.ts requestUploadUrl uses cached bucket lookup instead of per-request SQL query
Contributor
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds an LRU cache for bucket metadata in the presigned-url-plugin. Previously, every
requestUploadUrlcall queried thebucketstable even though bucket config (type, allowed_mime_types, max_file_size, etc.) is essentially static. Now the first request perdatabaseId:bucketKeypair hits the DB, and subsequent requests are served from cache.Cache details:
bucket:${databaseId}:${bucketKey}max: 500entries (vs 50 for storage module cache, since there are many more buckets)clearStorageModuleCache()now clears both caches (coordinated eviction)clearBucketCache(databaseId?)added for targeted per-database evictionFiles changed:
storage-module-cache.ts— newbucketCacheLRU,getBucketConfig(),clearBucketCache()plugin.ts—requestUploadUrlnow callsgetBucketConfig()instead of inline SQLindex.ts— exportsgetBucketConfigandclearBucketCacheReview & Testing Checklist for Human
allowed_mime_typesormax_file_sizeis updated, or a bucket is deleted, the cache will serve stale data for up to TTL (1hr prod). Confirm this is acceptable, or whether a cache-bust hook is needed on bucket DDL/DML.clearBucketCacheprefix-scan eviction. Consider whether tests should be added before merge.Suggested manual test: Call
requestUploadUrltwice with the same bucket key and verify the second call doesn't produce aBucket cache missdebug log line.Notes
bucketsQualifiedNameinterpolation in the SQL query is carried over from the previous inline query — not a new pattern.clearBucketCacheiteratesbucketCache.keys()while deleting; this is safe withlru-cachev10's iterator implementation, but worth being aware of.Link to Devin session: https://app.devin.ai/sessions/4c882ba2dfbf4045adf85fb83cde6f77
Requested by: @pyramation