IWatcher.php 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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. }