aboutsummaryrefslogtreecommitdiffstats
path: root/lib/public/Collaboration
diff options
context:
space:
mode:
authorJulius Härtl <jus@bitgrid.net>2022-08-30 19:53:12 +0200
committerJulius Härtl <jus@bitgrid.net>2022-08-31 16:24:35 +0200
commit80f6a5834ab9e679c1a0df6a1aee82107ca5cfe3 (patch)
treeb493860f52e4fe7b358ecb91897eb19b7da1caac /lib/public/Collaboration
parenta392235e23c3b8af1d0eba4dbac18b18de826a1c (diff)
downloadnextcloud-server-80f6a5834ab9e679c1a0df6a1aee82107ca5cfe3.tar.gz
nextcloud-server-80f6a5834ab9e679c1a0df6a1aee82107ca5cfe3.zip
Refactor cache handling
Signed-off-by: Julius Härtl <jus@bitgrid.net>
Diffstat (limited to 'lib/public/Collaboration')
-rw-r--r--lib/public/Collaboration/Reference/IReferenceManager.php23
-rw-r--r--lib/public/Collaboration/Reference/IReferenceProvider.php7
2 files changed, 28 insertions, 2 deletions
diff --git a/lib/public/Collaboration/Reference/IReferenceManager.php b/lib/public/Collaboration/Reference/IReferenceManager.php
index e9a53e8a61a..487e243c7ed 100644
--- a/lib/public/Collaboration/Reference/IReferenceManager.php
+++ b/lib/public/Collaboration/Reference/IReferenceManager.php
@@ -31,6 +31,7 @@ interface IReferenceManager {
/**
* Return all reference identifiers within a string as an array
*
+ * @return string[] Array of found references (urls)
* @since 25.0.0
*/
public function extractReferences(string $text): array;
@@ -44,4 +45,26 @@ interface IReferenceManager {
* @since 25.0.0
*/
public function resolveReference(string $referenceId): ?IReference;
+
+ /**
+ * Get a reference by its cache key
+ *
+ * @since 25.0.0
+ */
+ public function getReferenceByCacheKey(string $cacheKey): ?IReference;
+
+ /**
+ * Explicitly get a reference from the cache to avoid heavy fetches for cases
+ * the cache can then be filled with a separate request from the frontend
+ *
+ * @since 25.0.0
+ */
+ public function getReferenceFromCache(string $referenceId): ?IReference;
+
+ /**
+ * Invalidate all cache entries with a prefix or just one if the cache key is provided
+ *
+ * @since 25.0.0
+ */
+ public function invalidateCache(string $cachePrefix, ?string $cacheKey = null): void;
}
diff --git a/lib/public/Collaboration/Reference/IReferenceProvider.php b/lib/public/Collaboration/Reference/IReferenceProvider.php
index d2f3601a475..100374b78b3 100644
--- a/lib/public/Collaboration/Reference/IReferenceProvider.php
+++ b/lib/public/Collaboration/Reference/IReferenceProvider.php
@@ -47,14 +47,17 @@ interface IReferenceProvider {
*
* @since 25.0.0
*/
- public function isGloballyCacheable(): bool;
+ public function getCachePrefix(string $referenceId): string;
/**
* Return a custom cache key to be used for caching the metadata
* This could be for example the current user id if the reference
* access permissions are different for each user
*
+ * Should return null, if the cache is only related to the
+ * reference id and has no further dependency
+ *
* @since 25.0.0
*/
- public function getCacheKey(string $referenceId): string;
+ public function getCacheKey(string $referenceId): ?string;
}