MarkerService.php 698 B

12345678910111213141516171819202122232425262728
  1. <?php
  2. namespace App\Services;
  3. use Cache;
  4. class MarkerService
  5. {
  6. const CACHE_KEY = 'pf:services:markers:timeline:';
  7. public static function get($profileId, $timeline = 'home')
  8. {
  9. return Cache::get(self::CACHE_KEY . $timeline . ':' . $profileId);
  10. }
  11. public static function set($profileId, $timeline = 'home', $entityId = false)
  12. {
  13. $existing = self::get($profileId, $timeline);
  14. $key = self::CACHE_KEY . $timeline . ':' . $profileId;
  15. $val = [
  16. 'last_read_id' => (string) $entityId,
  17. 'version' => $existing ? ($existing['version'] + 1) : 1,
  18. 'updated_at' => str_replace('+00:00', 'Z', now()->format(DATE_RFC3339_EXTENDED))
  19. ];
  20. Cache::put($key, $val, 2592000);
  21. return $val;
  22. }
  23. }