LogEventService.php 691B

123456789101112131415161718192021222324252627282930
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: guanxl
  5. * Date: 2018/7/27
  6. * Time: 11:45
  7. * 记录用户操作日志,例如用户上下线,用户答题
  8. */
  9. namespace App\Services;
  10. use App\Traits\Singleton;
  11. class LogEventService
  12. {
  13. use Singleton;
  14. const REDIS_KEY="log_event:brainstorming";
  15. public function push($activityId,$userId,$channel,$event,$data=[]){
  16. $redisData = [
  17. "activity_id" => $activityId,
  18. "user_id" => $userId,
  19. "channel" => $channel,
  20. "event" => $event,
  21. "event_time" => time(),
  22. "data" => $data
  23. ];
  24. app("redisLog")->lPush(self::REDIS_KEY,json_encode($redisData));
  25. }
  26. }