IWatcher.php 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. <?php
  2. /**
  3. * @copyright Copyright (c) 2016, ownCloud, Inc.
  4. *
  5. * @author Christoph Wurst <christoph@winzerhof-wurst.at>
  6. * @author Robin Appelman <robin@icewind.nl>
  7. *
  8. * @license AGPL-3.0
  9. *
  10. * This code is free software: you can redistribute it and/or modify
  11. * it under the terms of the GNU Affero General Public License, version 3,
  12. * as published by the Free Software Foundation.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU Affero General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU Affero General Public License, version 3,
  20. * along with this program. If not, see <http://www.gnu.org/licenses/>
  21. *
  22. */
  23. namespace OCP\Files\Cache;
  24. /**
  25. * check the storage backends for updates and change the cache accordingly
  26. *
  27. * @since 9.0.0
  28. */
  29. interface IWatcher {
  30. /**
  31. * @since 9.0.0
  32. */
  33. public const CHECK_NEVER = 0; // never check the underlying filesystem for updates
  34. /**
  35. * @since 9.0.0
  36. */
  37. public const CHECK_ONCE = 1; // check the underlying filesystem for updates once every request for each file
  38. /**
  39. * @since 9.0.0
  40. */
  41. public const CHECK_ALWAYS = 2; // always check the underlying filesystem for updates
  42. /**
  43. * @param int $policy either IWatcher::CHECK_NEVER, IWatcher::CHECK_ONCE, IWatcher::CHECK_ALWAYS
  44. * @since 9.0.0
  45. */
  46. public function setPolicy($policy);
  47. /**
  48. * @return int either IWatcher::CHECK_NEVER, IWatcher::CHECK_ONCE, IWatcher::CHECK_ALWAYS
  49. * @since 9.0.0
  50. */
  51. public function getPolicy();
  52. /**
  53. * check $path for updates and update if needed
  54. *
  55. * @param string $path
  56. * @param ICacheEntry|null $cachedEntry
  57. * @return boolean true if path was updated
  58. * @since 9.0.0
  59. */
  60. public function checkUpdate($path, $cachedEntry = null);
  61. /**
  62. * Update the cache for changes to $path
  63. *
  64. * @param string $path
  65. * @param ICacheEntry $cachedData
  66. * @since 9.0.0
  67. */
  68. public function update($path, $cachedData);
  69. /**
  70. * Check if the cache for $path needs to be updated
  71. *
  72. * @param string $path
  73. * @param ICacheEntry $cachedData
  74. * @return bool
  75. * @since 9.0.0
  76. */
  77. public function needsUpdate($path, $cachedData);
  78. /**
  79. * remove deleted files in $path from the cache
  80. *
  81. * @param string $path
  82. * @since 9.0.0
  83. */
  84. public function cleanFolder($path);
  85. }