-
Notifications
You must be signed in to change notification settings - Fork 0
Feature: simplify response cache data structure to optimize performance #17
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
Feature: simplify response cache data structure to optimize performance #17
Conversation
… dependency - replace Any cache values with ByteArrayContent for type safety - implement byte extraction and serialization for ByteArrayContent - simplify redis cache serialization/deserialization without gson - use lazy initialization for Redis client instance - improve cache get retry logic with repeat and early return - remove gson imports and related code for cleaner dependencies
- add default ContentType.Application.OctetStream on parse failure with warning log - simplify cache put method by removing unnecessary cast in memory cache provider
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR simplifies the response cache data structure by replacing generic Any cache values with strongly-typed ByteArrayContent for improved type safety and performance. The implementation removes Gson dependency in favor of native byte array serialization and adds lazy initialization for Redis connections.
- Replaced
Anycache values withByteArrayContentfor type safety - Removed Gson dependency and implemented custom byte array serialization/deserialization
- Added lazy initialization for Redis client and connection instances
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| ui/packages/api-client/src/base.ts | Updated BASE_PATH from localhost URL to relative path |
| gradle/libs.versions.toml | Removed Gson library dependency |
| app/src/main/kotlin/io/sakurasou/hoshizora/plugins/Cache.kt | Refactored cache system to use ByteArrayContent, removed Gson, added lazy Redis initialization |
| app/build.gradle.kts | Removed Gson implementation dependency |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| if (expireTime == null) { | ||
| provider.saveCache(key, body) | ||
| provider.saveCache(key, body as ByteArrayContent) | ||
| } else { | ||
| provider.saveCache(key, body, expireTime) | ||
| provider.saveCache(key, body as ByteArrayContent, expireTime) |
Copilot
AI
Sep 2, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unsafe casting of body to ByteArrayContent without type checking. If body is not a ByteArrayContent instance, this will cause a ClassCastException at runtime. Consider using safe casting (body as? ByteArrayContent) or type checking before casting.
| if (expireTime == null) { | ||
| provider.saveCache(key, body) | ||
| provider.saveCache(key, body as ByteArrayContent) | ||
| } else { | ||
| provider.saveCache(key, body, expireTime) | ||
| provider.saveCache(key, body as ByteArrayContent, expireTime) |
Copilot
AI
Sep 2, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unsafe casting of body to ByteArrayContent without type checking. If body is not a ByteArrayContent instance, this will cause a ClassCastException at runtime. Consider using safe casting (body as? ByteArrayContent) or type checking before casting.
Co-authored-by: Copilot <[email protected]>
Uh oh!
There was an error while loading. Please reload this page.