Exemplo n.º 1
0
 /**
  * Store the cache.
  *
  * @return void
  */
 public function save()
 {
     $contents = $this->getForStorage();
     if ($this->ttl !== null) {
         $this->client->put($this->key, $contents, $this->ttl);
     } else {
         $this->client->forever($this->key, $contents);
     }
 }
Exemplo n.º 2
0
 /**
  * Get the given user's permissions.
  *
  * @param  \Illuminate\Database\Eloquent\Model  $user
  * @return \Illuminate\Database\Eloquent\Collection
  */
 public function getPermissions(Model $user)
 {
     $key = $this->tag . '-permissions-' . $user->getKey();
     if ($permissions = $this->cache->get($key)) {
         return $this->deserializePermissions($permissions);
     }
     $permissions = parent::getPermissions($user);
     $this->cache->forever($key, $this->serializePermissions($permissions));
     return $permissions;
 }
Exemplo n.º 3
0
 /**
  * Get the given user's abilities.
  *
  * @param  \Illuminate\Database\Eloquent\Model  $user
  * @return \Illuminate\Database\Eloquent\Collection
  */
 public function getAbilities(Model $user)
 {
     $key = $this->tag . '-abilities-' . $user->getKey();
     if ($abilities = $this->cache->get($key)) {
         return $this->deserializeAbilities($abilities);
     }
     $abilities = parent::getAbilities($user);
     $this->cache->forever($key, $this->serializeAbilities($abilities));
     return $abilities;
 }
Exemplo n.º 4
0
 /**
  * Get an item from the cache, or store the default value forever.
  *
  * @param  string  $key
  * @param  callable  $callback
  * @return mixed
  */
 protected function sear($key, callable $callback)
 {
     if (is_null($value = $this->cache->get($key))) {
         $this->cache->forever($key, $value = $callback());
     }
     return $value;
 }
Exemplo n.º 5
0
 /**
  * Store an item in the cache indefinitely.
  *
  * @param  string  $key
  * @param  mixed   $value
  * @return void
  */
 public function forever($key, $value)
 {
     $this->store->forever($this->taggedItemKey($key), $value);
 }
Exemplo n.º 6
0
 /**
  * Store an item in the cache indefinitely.
  *
  * @param  string  $key
  * @param  mixed   $value
  * @return void
  */
 public function forever($key, $value)
 {
     $this->store->forever($key, $value);
     $this->fireCacheEvent('write', [$key, $value, 0]);
 }
Exemplo n.º 7
0
 /**
  * Reset the tag and return the new tag identifier.
  *
  * @param string $name        	
  * @return string
  */
 public function resetTag($name)
 {
     $this->store->forever($this->tagKey($name), $id = str_replace('.', '', uniqid('', true)));
     return $id;
 }
 /**
  * Store an item in the cache indefinitely.
  *
  * @param  string $key
  * @param  mixed  $value
  *
  * @return void
  */
 public function forever($key, $value)
 {
     $this->store->forever($key, $value);
 }