/** * {@inheritDoc} */ public function read($sessionId) { if ($this->files->exists($path = $this->path . DS . $sessionId)) { return $this->files->get($path); } return ''; }
/** * Retrieve an item and expiry time from the cache by key. * * @param string $key * @return array */ protected function getPayload($key) { $path = $this->path($key); // If the file doesn't exists, we obviously can't return the cache so we will // just return null. Otherwise, we'll get the contents of the file and get // the expiration UNIX timestamps from the start of the file's contents. if (!$this->files->exists($path)) { return array('data' => null, 'time' => null); } try { $expire = substr($contents = $this->files->get($path), 0, 10); } catch (\Exception $e) { return array('data' => null, 'time' => null); } // If the current time is greater than expiration timestamps we will delete // the file and return null. This helps clean up the old files and keeps // this directory much cleaner for us as old files aren't hanging out. if (time() >= $expire) { $this->forget($key); return array('data' => null, 'time' => null); } $data = unserialize(substr($contents, 10)); // Next, we'll extract the number of minutes that are remaining for a cache // so that we can properly retain the time for things like the increment // operation that may be performed on the cache. We'll round this out. $time = ceil(($expire - time()) / 60); return compact('data', 'time'); }
/** * Load the service provider manifest JSON file. * * @return array */ public function loadManifest() { $path = $this->manifestPath . '/services.json'; // The service manifest is a file containing a JSON representation of every // service provided by the application and whether its provider is using // deferred loading or should be eagerly loaded on each request to us. if ($this->files->exists($path)) { $manifest = json_decode($this->files->get($path), true); return array_merge($this->default, $manifest); } }