nextcloud / nextcloud/server

Add getCacheTTL() method to IReferenceProvider interface

Open
#56,072 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

0. Needs triage enhancement
Dominant language
PHP
Stars
36.9k
Forks
5.2k
Avg merge
2d 3h
Merged PRs (30d)
713

Description

How to use GitHub
  • Please use the 👍 reaction to show that you are interested into the same feature.
  • Please don't comment if you have no relevant information to add. It's just extra noise for everyone subscribed to this issue.
  • Subscribe to receive notifications on status change and new comments.

Is your feature request related to a problem? Please describe.

  1. External API Integrations: Ticketing systems (Zammad, GitHub issues) with data that updates frequently
  2. Configuration Management: Systems like iTop with dynamic configuration changes
  3. Real-time Data: Any provider that needs sub-hourly cache invalidation

PR #56013 attempted to implement support for custom cache TTLs in the ReferenceManager, but discovered that the getCacheTTL() method referenced in issue #56012 does not actually exist in the IReferenceProvider interface.

Currently, ReferenceManager::resolveReference() always caches resolved references with a hardcoded 3600 second TTL, regardless of the provider's needs.

Current Behavior
Reference providers cannot specify custom cache durations. All cached references use the hardcoded CACHE_TTL = 3600 constant.

This is problematic for providers that manage frequently-changing data (e.g., external API integrations, ticketing systems, configuration management) that need shorter cache durations.

Describe the solution you'd like
Add a new optional method getCacheTTL() to the IReferenceProvider interface:

/**
 * Return the custom cache TTL for this provider's references in seconds
 * Return null to use the default CACHE_TTL (3600 seconds)
 *
 * @since 30.0.0
 * @return int|null The cache TTL in seconds, or null for default
 */
public function getCacheTTL(): ?int;

Describe alternatives you've considered
None

Additional context
Implementation Details

  • The method should return an integer (seconds) or null (to use default 3600s)
  • Makes it possible for ReferenceManager to respect provider-specific TTLs
  • Maintains backward compatibility - providers that don't implement this method will default to 3600s
  • Enables providers like external integrations to use shorter TTLs (e.g., 60-300 seconds) for real-time data

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the IReferenceProvider interface and ReferenceManager::resolveReference(), then review PR #56013 and issue #56012 for the surrounding cache-TTL context. The work is complete when providers can supply a TTL while references without one continue using the default 3600-second cache duration.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
backend
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.