1
0

IFileAccess.php 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * @copyright Copyright (c) 2024 Robin Appelman <robin@icewind.nl>
  5. *
  6. * @author Robin Appelman <robin@icewind.nl>
  7. *
  8. * @license GNU AGPL version 3 or any later version
  9. *
  10. * This program is free software: you can redistribute it and/or modify
  11. * it under the terms of the GNU Affero General Public License as
  12. * published by the Free Software Foundation, either version 3 of the
  13. * License, or (at your option) any later version.
  14. *
  15. * This program is distributed in the hope that it will be useful,
  16. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. * GNU Affero General Public License for more details.
  19. *
  20. * You should have received a copy of the GNU Affero General Public License
  21. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  22. *
  23. */
  24. namespace OCP\Files\Cache;
  25. /**
  26. * Low level access to the file cache.
  27. *
  28. * This is intended for use cases where data from the filecache needs to be loaded, but the full filesystem apis are
  29. * insufficient or too inefficient for the use-case.
  30. *
  31. * @since 29.0.0
  32. */
  33. interface IFileAccess {
  34. /**
  35. * Get a filecache data by file id from a specific storage.
  36. *
  37. * This is preferred over `getByFileId` when the storage id is known as it
  38. * can be more efficient in some setups.
  39. *
  40. * @param int $fileId
  41. * @param int $storageId
  42. * @return ICacheEntry|null
  43. *
  44. * @since 29.0.0
  45. */
  46. public function getByFileIdInStorage(int $fileId, int $storageId): ?ICacheEntry;
  47. /**
  48. * Get a filecache data by path and storage id.
  49. *
  50. * @param string $path
  51. * @param int $storageId
  52. * @return ICacheEntry|null
  53. *
  54. * @since 29.0.0
  55. */
  56. public function getByPathInStorage(string $path, int $storageId): ?ICacheEntry;
  57. /**
  58. * Get a filecache data by file id.
  59. *
  60. * If the storage id is known then `getByFileIdInStorage` is preferred as it can be more efficient in some setups.
  61. *
  62. * @param int $fileId
  63. * @return ICacheEntry|null
  64. *
  65. * @since 29.0.0
  66. */
  67. public function getByFileId(int $fileId): ?ICacheEntry;
  68. /**
  69. * Get filecache data by file ids.
  70. *
  71. * If the storage id is known then `getByFileIdsInStorage` is preferred as it can be more efficient in some setups.
  72. *
  73. * @param int[] $fileIds
  74. * @return array<int, ICacheEntry>
  75. *
  76. * @since 29.0.0
  77. */
  78. public function getByFileIds(array $fileIds): array;
  79. /**
  80. * Get filecache data by file ids from a specific storage.
  81. *
  82. * This is prefered over `getByFileIds` when the storage id is known as it
  83. * can be more efficient in some setups.
  84. *
  85. * @param int[] $fileIds
  86. * @param int $storageId
  87. * @return array<int, ICacheEntry>
  88. *
  89. * @since 29.0.0
  90. */
  91. public function getByFileIdsInStorage(array $fileIds, int $storageId): array;
  92. }