Skip to content

Commit

Permalink
use property_exists
Browse files Browse the repository at this point in the history
  • Loading branch information
themsaid committed Mar 28, 2019
1 parent 3719758 commit eb3f6f8
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/Watchers/CacheWatcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public function recordKeyWritten(KeyWritten $event)
'type' => 'set',
'key' => $event->key,
'value' => $event->value,
'expiration' => $event->seconds ?? $event->minutes,
'expiration' => $this->formatExpiration($event),
]));
}

Expand All @@ -102,6 +102,16 @@ public function recordKeyForgotten(KeyForgotten $event)
]));
}

/**
* @param \Illuminate\Cache\Events\KeyWritten $event
* @return mixed
*/
protected function formatExpiration(KeyWritten $event)
{
return property_exists($event, 'seconds')
? $event->seconds : $event->minutes * 60;
}

/**
* Determine if the event should be ignored.
*
Expand Down

0 comments on commit eb3f6f8

Please sign in to comment.