IWatcher.php 2.2 KB

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