Skip to content

Commit 3dc3ee4

Browse files
committed
feat: add public interface for CacheAccess
Signed-off-by: Robin Appelman <robin@icewind.nl>
1 parent 637d8ec commit 3dc3ee4

4 files changed

Lines changed: 80 additions & 1 deletion

File tree

lib/composer/composer/autoload_classmap.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,7 @@
317317
'OCP\\Files\\Cache\\CacheInsertEvent' => $baseDir . '/lib/public/Files/Cache/CacheInsertEvent.php',
318318
'OCP\\Files\\Cache\\CacheUpdateEvent' => $baseDir . '/lib/public/Files/Cache/CacheUpdateEvent.php',
319319
'OCP\\Files\\Cache\\ICache' => $baseDir . '/lib/public/Files/Cache/ICache.php',
320+
'OCP\\Files\\Cache\\ICacheAccess' => $baseDir . '/lib/public/Files/Cache/ICacheAccess.php',
320321
'OCP\\Files\\Cache\\ICacheEntry' => $baseDir . '/lib/public/Files/Cache/ICacheEntry.php',
321322
'OCP\\Files\\Cache\\ICacheEvent' => $baseDir . '/lib/public/Files/Cache/ICacheEvent.php',
322323
'OCP\\Files\\Cache\\IPropagator' => $baseDir . '/lib/public/Files/Cache/IPropagator.php',

lib/composer/composer/autoload_static.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -350,6 +350,7 @@ class ComposerStaticInit749170dad3f5e7f9ca158f5a9f04f6a2
350350
'OCP\\Files\\Cache\\CacheInsertEvent' => __DIR__ . '/../../..' . '/lib/public/Files/Cache/CacheInsertEvent.php',
351351
'OCP\\Files\\Cache\\CacheUpdateEvent' => __DIR__ . '/../../..' . '/lib/public/Files/Cache/CacheUpdateEvent.php',
352352
'OCP\\Files\\Cache\\ICache' => __DIR__ . '/../../..' . '/lib/public/Files/Cache/ICache.php',
353+
'OCP\\Files\\Cache\\ICacheAccess' => __DIR__ . '/../../..' . '/lib/public/Files/Cache/ICacheAccess.php',
353354
'OCP\\Files\\Cache\\ICacheEntry' => __DIR__ . '/../../..' . '/lib/public/Files/Cache/ICacheEntry.php',
354355
'OCP\\Files\\Cache\\ICacheEvent' => __DIR__ . '/../../..' . '/lib/public/Files/Cache/ICacheEvent.php',
355356
'OCP\\Files\\Cache\\IPropagator' => __DIR__ . '/../../..' . '/lib/public/Files/Cache/IPropagator.php',

lib/private/Files/Cache/CacheAccess.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,15 @@
55
use OC\FilesMetadata\FilesMetadataManager;
66
use OC\SystemConfig;
77
use OCP\DB\QueryBuilder\IQueryBuilder;
8+
use OCP\Files\Cache\ICacheAccess;
89
use OCP\Files\IMimeTypeLoader;
910
use OCP\IDBConnection;
1011
use Psr\Log\LoggerInterface;
1112

1213
/**
1314
* Lower level access to the file cache
1415
*/
15-
class CacheAccess {
16+
class CacheAccess implements ICacheAccess {
1617
public function __construct(
1718
private IDBConnection $connection,
1819
private SystemConfig $systemConfig,
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
<?php
2+
3+
namespace OCP\Files\Cache;
4+
5+
/**
6+
* Low level access to the file cache.
7+
*
8+
* This is intended for use cases where data from the filecache needs to be loaded by the full filesystem apis are
9+
* insufficient or to inefficient.
10+
*
11+
* @since 29.0.0
12+
*/
13+
interface ICacheAccess {
14+
/**
15+
* Get a filecache data by file id from a specific storage.
16+
*
17+
* This is preferred over `getByFileId` when the storage id is known as it
18+
* can be more efficient in some setups.
19+
*
20+
* @param int $fileId
21+
* @param int $storageId
22+
* @return ICacheEntry|null
23+
*
24+
* @since 29.0.0
25+
*/
26+
public function getByFileIdInStorage(int $fileId, int $storageId): ?ICacheEntry;
27+
28+
/**
29+
* Get a filecache data by path and storage id.
30+
*
31+
* @param string $path
32+
* @param int $storageId
33+
* @return ICacheEntry|null
34+
*
35+
* @since 29.0.0
36+
*/
37+
public function getByPathInStorage(string $path, int $storageId): ?ICacheEntry ;
38+
39+
/**
40+
* Get a filecache data by file id.
41+
*
42+
* If the storage id is known than `getByFileIdInStorage` is preferred as it can be more efficient in some setups.
43+
*
44+
* @param int $fileId
45+
* @return ICacheEntry|null
46+
*
47+
* @since 29.0.0
48+
*/
49+
public function getByFileId(int $fileId): ?ICacheEntry;
50+
51+
/**
52+
* Get filecache data by file ids.
53+
*
54+
* If the storage id is known than `getByFileIdsInStorage` is preferred as it can be more efficient in some setups.
55+
*
56+
* @param int[] $fileIds
57+
* @return array<int, ICacheEntry>
58+
*
59+
* @since 29.0.0
60+
*/
61+
public function getByFileIds(array $fileIds): array;
62+
63+
/**
64+
* Get filecache data by file ids from a specific storage.
65+
*
66+
* This is prefered over `getByFileIds` when the storage id is known as it
67+
* can be more efficient in some setups.
68+
*
69+
* @param int[] $fileIds
70+
* @param int $storageId
71+
* @return array<int, ICacheEntry>
72+
*
73+
* @since 29.0.0
74+
*/
75+
public function getByFileIdsInStorage(array $fileIds, int $storageId): array;
76+
}

0 commit comments

Comments
 (0)