Cache.php 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. <?php
  2. namespace Illuminate\Support\Facades;
  3. use Mockery;
  4. /**
  5. * @method static \Illuminate\Contracts\Cache\Repository store(string|null $name = null)
  6. * @method static \Illuminate\Contracts\Cache\Repository driver(string|null $driver = null)
  7. * @method static \Illuminate\Contracts\Cache\Repository memo(string|null $driver = null)
  8. * @method static \Illuminate\Contracts\Cache\Repository resolve(string $name)
  9. * @method static \Illuminate\Cache\Repository build(array $config)
  10. * @method static \Illuminate\Cache\Repository repository(\Illuminate\Contracts\Cache\Store $store, array $config = [])
  11. * @method static void refreshEventDispatcher()
  12. * @method static string getDefaultDriver()
  13. * @method static void setDefaultDriver(string $name)
  14. * @method static \Illuminate\Cache\CacheManager forgetDriver(array|string|null $name = null)
  15. * @method static void purge(string|null $name = null)
  16. * @method static \Illuminate\Cache\CacheManager extend(string $driver, \Closure $callback)
  17. * @method static \Illuminate\Cache\CacheManager setApplication(\Illuminate\Contracts\Foundation\Application $app)
  18. * @method static bool has(\UnitEnum|array|string $key)
  19. * @method static bool missing(\UnitEnum|string $key)
  20. * @method static mixed get(\UnitEnum|array|string $key, mixed $default = null)
  21. * @method static array many(array $keys)
  22. * @method static iterable getMultiple(iterable $keys, mixed $default = null)
  23. * @method static mixed pull(\UnitEnum|array|string $key, mixed $default = null)
  24. * @method static string string(\UnitEnum|string $key, \Closure|string|null $default = null)
  25. * @method static int integer(\UnitEnum|string $key, \Closure|int|null $default = null)
  26. * @method static float float(\UnitEnum|string $key, \Closure|float|null $default = null)
  27. * @method static bool boolean(\UnitEnum|string $key, \Closure|bool|null $default = null)
  28. * @method static array array(\UnitEnum|string $key, \Closure|array|null $default = null)
  29. * @method static bool put(\UnitEnum|array|string $key, mixed $value, \DateTimeInterface|\DateInterval|int|null $ttl = null)
  30. * @method static bool set(\UnitEnum|array|string $key, mixed $value, \DateTimeInterface|\DateInterval|int|null $ttl = null)
  31. * @method static bool putMany(array $values, \DateTimeInterface|\DateInterval|int|null $ttl = null)
  32. * @method static bool setMultiple(iterable $values, null|int|\DateInterval $ttl = null)
  33. * @method static bool add(\UnitEnum|array|string $key, mixed $value, \DateTimeInterface|\DateInterval|int|null $ttl = null)
  34. * @method static int|bool increment(\UnitEnum|string $key, mixed $value = 1)
  35. * @method static int|bool decrement(\UnitEnum|string $key, mixed $value = 1)
  36. * @method static bool forever(\UnitEnum|string $key, mixed $value)
  37. * @method static mixed remember(\UnitEnum|string $key, \Closure|\DateTimeInterface|\DateInterval|int|null $ttl, \Closure $callback)
  38. * @method static mixed sear(\UnitEnum|string $key, \Closure $callback)
  39. * @method static mixed rememberForever(\UnitEnum|string $key, \Closure $callback)
  40. * @method static mixed flexible(\UnitEnum|string $key, array $ttl, callable $callback, array|null $lock = null, bool $alwaysDefer = false)
  41. * @method static mixed withoutOverlapping(\UnitEnum|string $key, callable $callback, int $lockFor = 0, int $waitFor = 10, string|null $owner = null)
  42. * @method static \Illuminate\Cache\Limiters\ConcurrencyLimiterBuilder funnel(\UnitEnum|string $name)
  43. * @method static bool forget(\UnitEnum|array|string $key)
  44. * @method static bool delete(\UnitEnum|array|string $key)
  45. * @method static bool deleteMultiple(iterable $keys)
  46. * @method static bool clear()
  47. * @method static \Illuminate\Cache\TaggedCache tags(mixed $names)
  48. * @method static string|null getName()
  49. * @method static bool supportsTags()
  50. * @method static int|null getDefaultCacheTime()
  51. * @method static \Illuminate\Cache\Repository setDefaultCacheTime(int|null $seconds)
  52. * @method static \Illuminate\Contracts\Cache\Store getStore()
  53. * @method static \Illuminate\Cache\Repository setStore(\Illuminate\Contracts\Cache\Store $store)
  54. * @method static \Illuminate\Contracts\Events\Dispatcher|null getEventDispatcher()
  55. * @method static void setEventDispatcher(\Illuminate\Contracts\Events\Dispatcher $events)
  56. * @method static void macro(string $name, object|callable $macro)
  57. * @method static void mixin(object $mixin, bool $replace = true)
  58. * @method static bool hasMacro(string $name)
  59. * @method static void flushMacros()
  60. * @method static mixed macroCall(string $method, array $parameters)
  61. * @method static bool flush()
  62. * @method static string getPrefix()
  63. * @method static \Illuminate\Contracts\Cache\Lock lock(string $name, int $seconds = 0, string|null $owner = null)
  64. * @method static \Illuminate\Contracts\Cache\Lock restoreLock(string $name, string $owner)
  65. *
  66. * @see \Illuminate\Cache\CacheManager
  67. * @see \Illuminate\Cache\Repository
  68. */
  69. class Cache extends Facade
  70. {
  71. /**
  72. * Get the registered name of the component.
  73. *
  74. * @return string
  75. */
  76. protected static function getFacadeAccessor()
  77. {
  78. return 'cache';
  79. }
  80. /**
  81. * Convert the facade into a Mockery spy.
  82. *
  83. * @return \Mockery\MockInterface
  84. */
  85. public static function spy()
  86. {
  87. if (! static::isMock()) {
  88. $class = static::getMockableClass();
  89. $instance = static::getFacadeRoot();
  90. if ($class && $instance) {
  91. return tap(Mockery::spy($instance)->makePartial(), function ($spy) {
  92. static::swap($spy);
  93. });
  94. }
  95. return tap($class ? Mockery::spy($class) : Mockery::spy(), function ($spy) {
  96. static::swap($spy);
  97. });
  98. }
  99. }
  100. }