1<?php 2 3/** 4 * Device Detector - The Universal Device Detection library for parsing User Agents 5 * 6 * @link https://matomo.org 7 * 8 * @license http://www.gnu.org/licenses/lgpl.html LGPL v3 or later 9 */ 10 11declare(strict_types=1); 12 13namespace DeviceDetector\Cache; 14 15use Illuminate\Support\Facades\Cache; 16 17class LaravelCache implements CacheInterface 18{ 19 /** 20 * @inheritDoc 21 */ 22 public function fetch(string $id) 23 { 24 return Cache::get($id); 25 } 26 27 /** 28 * @inheritDoc 29 */ 30 public function contains(string $id): bool 31 { 32 return Cache::has($id); 33 } 34 35 /** 36 * @inheritDoc 37 */ 38 public function save(string $id, $data, int $lifeTime = 0): bool 39 { 40 return Cache::put($id, $data, \func_num_args() < 3 ? null : $lifeTime); 41 } 42 43 /** 44 * @inheritDoc 45 */ 46 public function delete(string $id): bool 47 { 48 return Cache::forget($id); 49 } 50 51 /** 52 * @inheritDoc 53 */ 54 public function flushAll(): bool 55 { 56 return Cache::flush(); 57 } 58} 59