CacheAhead.php 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * This file is part of Hyperf.
  5. *
  6. * @link https://www.hyperf.io
  7. * @document https://hyperf.wiki
  8. * @contact group@hyperf.io
  9. * @license https://github.com/hyperf/hyperf/blob/master/LICENSE
  10. */
  11. namespace Hyperf\Cache\Annotation;
  12. use Attribute;
  13. use Hyperf\Di\Annotation\AbstractAnnotation;
  14. use Hyperf\Di\Annotation\AnnotationCollector;
  15. /**
  16. * Only Support Redis Driver.
  17. */
  18. #[Attribute(Attribute::TARGET_METHOD)]
  19. class CacheAhead extends AbstractAnnotation
  20. {
  21. /**
  22. * @param null|int $ttl the max offset for ttl
  23. */
  24. public function __construct(
  25. public ?string $prefix = null,
  26. public ?string $value = null,
  27. public ?int $ttl = null,
  28. public int $aheadSeconds = 0,
  29. public int $lockSeconds = 10,
  30. public int $offset = 0,
  31. public string $group = 'default',
  32. public bool $collect = false,
  33. public ?array $skipCacheResults = null
  34. ) {
  35. }
  36. public function collectMethod(string $className, ?string $target): void
  37. {
  38. AnnotationCollector::collectMethod($className, $target, static::class, $this);
  39. }
  40. }