Skip to content

Add configurable TTL for memory content caches#23

Open
AgentKush wants to merge 19 commits intoYumemiProject:develfrom
AgentKush:feature/cache-ttl-config
Open

Add configurable TTL for memory content caches#23
AgentKush wants to merge 19 commits intoYumemiProject:develfrom
AgentKush:feature/cache-ttl-config

Conversation

@AgentKush
Copy link

AppSettings:

  • Added KEY_CACHE_DETAILS_TTL (default: 5 min, range: 1-60)
  • Added KEY_CACHE_PAGES_TTL (default: 10 min, range: 1-120)
  • Added KEY_CACHE_RELATED_TTL (default: 10 min, range: 1-120)
  • Added getter properties with coerceIn bounds validation

MemoryContentCache:

  • Now injects AppSettings for TTL configuration
  • Uses configurable TTL values instead of hardcoded
  • Added KDoc explaining settings and restart requirement
  • Reformatted cache initialization for clarity

Note: Changes to cache TTL settings require app restart to take effect.

- Added Callback interface to ReaderMenuProvider for handling menu actions
- Implemented onOpenMangaInfo() in ReaderActivity to open manga details
- The info action now properly navigates to the manga details screen
…Model

- Replaced TODO comment with proper documentation explaining the early return logic
- The early return safely discards stale page position updates when content changes
- Replaced deprecated okhttp3.internal.platform.PlatformRegistry.applicationContext
- Now uses proper public API okhttp3.OkHttp.initialize() for OkHttp 5.x
- BasePageHolder: Implement onTrimMemory to properly handle memory pressure
  - TRIM_MEMORY_MODERATE or higher: recycle the image view
  - TRIM_MEMORY_BACKGROUND or higher: apply downsampling
- TypedListSpacingDecoration: Add vertical spacing for TIP list items
…wer state

- Replace hardcoded PREFETCH_LIMIT_DEFAULT with dynamic computation
- Adjust prefetch limit based on available RAM (2-10 pages)
- Reduce prefetch on metered networks (cellular) by 50%
- Reduce prefetch in power save mode by 50%
- Add PREFETCH_LIMIT_MINIMUM, PREFETCH_LIMIT_LOW, PREFETCH_LIMIT_HIGH constants
- Add isNetworkUnmetered() helper using NetworkCapabilities API
- Create ProxyWebViewUnsupportedException for better error handling
- Add localized string 'proxy_webview_not_supported' to strings.xml
- Update ProxyProvider to throw the new exception instead of generic IllegalArgumentException
- Add exception mapping in Throwable.kt for localized display message
- Import new exception in ExceptionResolver for future resolution support
- DetailsInteractor: Replace stale 'TODO: remove' with KDoc (class is in active use)
- AppRouter: Remove empty TODO from fragmentTag() extension
- ExternalMangaRepository: Clarify that external plugins don't support related manga
- Fragment.kt: Improve comment about container ancestor lookup behavior
- Preferences.kt: Fix MultiSelectListPreference.setDefaultValueCompat() to actually work
  (now checks if values is null/empty before setting, matching ListPreference behavior)
CSS Element Hiding (## rules):
- Add cssSelectors list to RulesList for storing element hiding rules
- Parse '##selector' rules and store CSS selectors
- Add elementHidingSelectors property for accessing selectors
- Add getElementHidingScript() to AdBlock for generating injectable JS
- Script creates <style> tag to hide matched elements with display:none

Domain Modifiers (domain= option):
- Parse 'domain=example.com|~exclude.com' modifier syntax
- Support both include (domain=x.com) and exclude (~x.com) domains
- Apply domain restrictions in Rule.WithModifiers.invoke()
- Extract baseDomain once for efficiency

Removes 4 TODO comments from adblock implementation.
- Refactor shareFile() to detect files vs directories
- Add shareSingleFile() for individual file sharing with proper MIME types
- Add shareDirectory() to share all files in a directory as multiple streams
- Support CBZ, CBR, ZIP file types with appropriate MIME types
- Filter hidden files when sharing directory contents
- Add new MIME type constants: TYPE_CBR, TYPE_ZIP, TYPE_OCTET_STREAM

This allows sharing local manga stored as directories (containing images)
in addition to the existing CBZ file support.
ReadButtonDelegate - Missing chapter handling:
- Add 'Select chapter' action to Snackbar when chapter is missing
- Change Snackbar duration to LENGTH_LONG for better visibility
- User can now quickly navigate to chapter list to pick another chapter
- Add 'select_chapter' string resource

CaptchaHandler - Clarify request retry:
- Replace ambiguous 'TODO check if ok' with explanatory comment
- Document that re-enqueuing request after captcha resolution is correct

DownloadNotificationFactory - Document cache behavior:
- Add comment explaining covers HashMap is bounded by active downloads
- Cache is simple and appropriate for notification icon use case

Removes 3 TODO comments with meaningful improvements.
- Updated from commit hash e205a8706e to tagged release 1.2
- Includes latest parser fixes and new source support from YakaTeam fork
- Tagged releases provide better stability than commit hashes
- Added KEY_JS_TIMEOUT setting with default of 4000ms (range: 2000-30000ms)
- Inject AppSettings into MangaLoaderContextImpl
- Use dynamic jsTimeoutMs property instead of hardcoded 4 seconds
- Helps with complex CloudFlare challenges that need more time to resolve
- Removed unused TimeUnit import
- Added BitmapCompressFormat enum with PNG, JPEG, WEBP, WEBP_LOSSLESS options
- Added overloaded compressTo() with format and quality parameters
- Maintains backward compatibility with original compressTo() method
- Handles API level differences for WebP formats gracefully
- Quality parameter (0-100) for lossy formats, ignored for lossless
- Better compression choices: JPEG for photos, WebP for modern efficiency
- Persist failed mirror sources to SharedPreferences across app restarts
- Add 24-hour TTL for blacklist entries (auto-expire and retry)
- Add clearBlacklist() method to manually reset all failed sources
- Add removeFromBlacklist() for individual source removal
- Add blacklistedSources property to query current blacklist state
- Load blacklist on init, cleanup expired entries before each check
- Handle unknown/removed sources gracefully during storage load
- Added @singleton annotation for proper DI lifecycle
ExternalPluginContentSource:
- Added getRelatedManga() method to query related manga from plugins
- Uses content URI: content://{authority}/manga/related/{url}
- Gracefully returns empty list if plugin doesn't support this feature
- Added COLUMN_RELATED_MANGA constant for capability detection

MangaSourceCapabilities:
- Added isRelatedMangaSupported flag (default: false for compatibility)
- Read from capabilities cursor during plugin initialization

ExternalMangaRepository:
- Updated getRelatedMangaImpl() to use plugin's related manga feature
- Checks capability before making content provider query
- Maintains backward compatibility with plugins that don't support it
- Configurable max retries (default: 3 attempts)
- Exponential backoff with jitter to prevent thundering herd
- Respects Retry-After header when present, caps at maxDelayMs
- Calculated delay formula: min(maxDelay, initialDelay * 2^retryCount) ± 25% jitter
- Default delays: 1s initial, 30s max, 2x multiplier
- Debug logging for retry attempts
- Fixed parseRetryAfter to handle HTTP date format properly
- Only throws TooManyRequestExceptions after all retries exhausted
ProxyBlacklistManager (new):
- Singleton class managing persistent host blacklist
- SharedPreferences storage with timestamps for TTL
- 6-hour expiration for blacklist entries
- Thread-safe with synchronized access
- Methods: isBlacklisted(), addToBlacklist(), removeFromBlacklist(), clearBlacklist()

BaseImageProxyInterceptor:
- Now accepts optional ProxyBlacklistManager parameter
- Removed in-memory ArraySet blacklist
- Delegates to manager for blacklist operations
- Backward compatible with null manager

WsrvNlProxyInterceptor / ZeroMsProxyInterceptor:
- Updated constructors to accept blacklist manager

RealImageProxyInterceptor:
- Injects ProxyBlacklistManager via Hilt
- Passes manager to child interceptors on creation
AppSettings:
- Added KEY_CACHE_DETAILS_TTL (default: 5 min, range: 1-60)
- Added KEY_CACHE_PAGES_TTL (default: 10 min, range: 1-120)
- Added KEY_CACHE_RELATED_TTL (default: 10 min, range: 1-120)
- Added getter properties with coerceIn bounds validation

MemoryContentCache:
- Now injects AppSettings for TTL configuration
- Uses configurable TTL values instead of hardcoded
- Added KDoc explaining settings and restart requirement
- Reformatted cache initialization for clarity

Note: Changes to cache TTL settings require app restart to take effect.
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.

1 participant