IWatcher.php 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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. public const CHECK_NEVER = 0; // never check the underlying filesystem for updates
  31. public const CHECK_ONCE = 1; // check the underlying filesystem for updates once every request for each file
  32. public const CHECK_ALWAYS = 2; // always check the underlying filesystem for updates
  33. /**
  34. * @param int $policy either IWatcher::CHECK_NEVER, IWatcher::CHECK_ONCE, IWatcher::CHECK_ALWAYS
  35. * @since 9.0.0
  36. */
  37. public function setPolicy($policy);
  38. /**
  39. * @return int either IWatcher::CHECK_NEVER, IWatcher::CHECK_ONCE, IWatcher::CHECK_ALWAYS
  40. * @since 9.0.0
  41. */
  42. public function getPolicy();
  43. /**
  44. * check $path for updates and update if needed
  45. *
  46. * @param string $path
  47. * @param ICacheEntry|null $cachedEntry
  48. * @return boolean true if path was updated
  49. * @since 9.0.0
  50. */
  51. public function checkUpdate($path, $cachedEntry = null);
  52. /**
  53. * Update the cache for changes to $path
  54. *
  55. * @param string $path
  56. * @param ICacheEntry $cachedData
  57. * @since 9.0.0
  58. */
  59. public function update($path, $cachedData);
  60. /**
  61. * Check if the cache for $path needs to be updated
  62. *
  63. * @param string $path
  64. * @param ICacheEntry $cachedData
  65. * @return bool
  66. * @since 9.0.0
  67. */
  68. public function needsUpdate($path, $cachedData);
  69. /**
  70. * remove deleted files in $path from the cache
  71. *
  72. * @param string $path
  73. * @since 9.0.0
  74. */
  75. public function cleanFolder($path);
  76. }