You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

usercache.php 1.5KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. <?php
  2. /**
  3. * Copyright (c) 2013 Thomas Tanghus (thomas@tanghus.net)
  4. * This file is licensed under the Affero General Public License version 3 or
  5. * later.
  6. * See the COPYING-README file.
  7. */
  8. namespace OC\Cache;
  9. /**
  10. * This interface defines method for accessing the file based user cache.
  11. */
  12. class UserCache implements \OCP\ICache {
  13. /**
  14. * @var \OC\Cache\File $userCache
  15. */
  16. protected $userCache;
  17. public function __construct() {
  18. $this->userCache = new File();
  19. }
  20. /**
  21. * Get a value from the user cache
  22. *
  23. * @param string $key
  24. * @return mixed
  25. */
  26. public function get($key) {
  27. return $this->userCache->get($key);
  28. }
  29. /**
  30. * Set a value in the user cache
  31. *
  32. * @param string $key
  33. * @param string $value
  34. * @param int $ttl Time To Live in seconds. Defaults to 60*60*24
  35. * @return bool
  36. */
  37. public function set($key, $value, $ttl = 0) {
  38. if (empty($key)) {
  39. return false;
  40. }
  41. return $this->userCache->set($key, $value, $ttl);
  42. }
  43. /**
  44. * Check if a value is set in the user cache
  45. *
  46. * @param string $key
  47. * @return bool
  48. */
  49. public function hasKey($key) {
  50. return $this->userCache->hasKey($key);
  51. }
  52. /**
  53. * Remove an item from the user cache
  54. *
  55. * @param string $key
  56. * @return bool
  57. */
  58. public function remove($key) {
  59. return $this->userCache->remove($key);
  60. }
  61. /**
  62. * clear the user cache of all entries starting with a prefix
  63. * @param string $prefix (optional)
  64. * @return bool
  65. */
  66. public function clear($prefix = '') {
  67. return $this->userCache->clear($prefix);
  68. }
  69. }