| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- <?php
- namespace App\Module\LCache;
- use App\Module\DelayQueue\Redis;
- use UCore\Helper\Logger;
- abstract class DQueueJob implements QueueJobInterface,DQueueJobInterface
- {
- use QueueCache;
- static public function getDelay(): int
- {
- return 2;
- }
- /**
- * 事件监听
- * @param $user
- *
- */
- static public function eventListen($user)
- {
- $arg2 = [];
- $indexs = static::getRequiredArgIndex();
- foreach ($indexs as $index) {
- if (!isset($user->$index)) {
- Logger::error("Cache-error", [ $user, $indexs, $index ]);
- throw new \InvalidArgumentException("参数错误");
- }
- $arg2[$index] = $user->$index;
- }
- static::jobUpdate($arg2);
- }
- /**
- * 使用任务更新
- *
- * @param $arg
- * @return void
- */
- static protected function jobUpdate($parameter)
- {
- Redis::addQueue([static::class, 'updateSync'], $parameter, static::getDelay());
- }
- }
|