Ejemplo n.º 1
0
 public function save()
 {
     // New and changed keys
     $changed = array_diff_assoc($this->data, $this->original);
     $insertValues = array();
     foreach ($changed as $name => $value) {
         if (!array_key_exists($name, $this->original)) {
             $insertValues[] = array('conf_name' => $name, 'conf_value' => $value);
             unset($changed[$name]);
         }
     }
     if (!empty($insertValues)) {
         $this->database->table('config')->insert($insertValues);
     }
     foreach ($changed as $name => $value) {
         $this->database->table('config')->where('conf_name', '=', $name)->update(array('conf_value' => $value));
     }
     // Deleted keys
     $deletedKeys = array_keys(array_diff_key($this->original, $this->data));
     if (!empty($deletedKeys)) {
         $this->database->table('config')->whereIn('conf_name', $deletedKeys)->delete();
     }
     // No need to cache old values anymore
     $this->original = $this->data;
     // Delete the cache so that it will be regenerated on the next request
     $this->cache->forget('fluxbb.config');
 }
 public function testShouldReturnIncrementalValues()
 {
     $this->repository->increment('memcached-testing');
     $this->assertSame(1, $this->repository->get('memcached-testing'));
     $this->repository->increment('memcached-testing', 100);
     $this->assertSame(101, $this->repository->get('memcached-testing'));
     $this->repository->decrement('memcached-testing', 100);
     $this->assertSame(1, $this->repository->get('memcached-testing'));
     $this->repository->decrement('memcached-testing', 100);
     $this->assertSame(0, $this->repository->get('memcached-testing'));
     $this->repository->forget('memcached-testing');
     $this->repository->decrement('memcached-testing', 100);
     $this->assertSame(0, $this->repository->get('memcached-testing'));
     $this->repository->forget('memcached-testing');
 }
 /**
  * clear all caches
  */
 public function clear()
 {
     $this->cache->forget(self::INDEX_KEY);
     foreach ($this->cache->get(self::CACHE_KEYS_KEY) as $key) {
         $this->cache->forget($key);
     }
     $this->cache->forget(self::CACHE_KEYS_KEY);
 }
Ejemplo n.º 4
0
 /**
  * Flush the cache for this Model Object instance
  *
  * @param Model $model
  * @return void
  */
 public function flush(Model $model)
 {
     // Assemble Cache Keys
     $keys[] = $this->resourceName . '.hash.' . $model->hash;
     $keys[] = $this->resourceName . '.id.' . $model->id;
     // Some keys will not be available on all models
     $referenceColumn = $this->referenceIdColumnName();
     if ($this->model->isFillable($referenceColumn)) {
         $keys[] = $this->resourceName . '.' . $referenceColumn . '.' . $model->{$referenceColumn};
     }
     // Clear the cache for the given keys
     foreach ($keys as $key) {
         $this->cache->forget($key);
     }
 }
Ejemplo n.º 5
0
 /**
  * Handle the form.
  *
  * @param  Repository                                 $cache
  * @param  Redirector                                 $redirect
  * @param                                             $key
  * @return \Symfony\Component\HttpFoundation\Response
  */
 public function handle(Repository $cache, Redirector $redirect, $key)
 {
     $parameters = $cache->get('form::' . $key);
     /* @var FormCriteria $criteria */
     $criteria = $this->dispatch(new GetFormCriteria($parameters));
     /* @var FormBuilder $builder */
     $builder = $criteria->build();
     $response = $builder->build()->post()->getFormResponse();
     $builder->flash();
     $cache->forget('form::' . $key);
     if ($response && $response->getStatusCode() !== 200) {
         return $response;
     }
     if ($builder->isAjax()) {
         return $builder->getFormResponse();
     }
     if ($builder->hasFormErrors()) {
         return $redirect->back();
     }
     return $response ?: $redirect->back();
 }
Ejemplo n.º 6
0
 /**
  * Remove an item from the cache.
  *
  * @param string $key
  * @return bool 
  * @static 
  */
 public static function forget($key)
 {
     return \Illuminate\Cache\Repository::forget($key);
 }
Ejemplo n.º 7
0
 /**
  * Remove an item from the cache.
  *
  * @param  mixed $key
  * @return bool
  */
 public function forget($key)
 {
     if (is_array($key)) {
         return $this->forgetMany($key);
     }
     return parent::forget($key);
 }
Ejemplo n.º 8
0
 /**
  * Forget settings cache.
  *
  * @return bool
  */
 public function forget()
 {
     return $this->cache->forget(self::CACHE_KEY);
 }
Ejemplo n.º 9
0
 /**
  * {@inheritDoc}
  */
 public function destroy($sessionId)
 {
     return $this->cache->forget($sessionId);
 }
Ejemplo n.º 10
0
 /**
  * 删除验证码
  * @param string $mobile
  * @param string $bag
  */
 public function forgetCodeFromCache($mobile, $bag)
 {
     $key = $this->getCacheKey($mobile, $bag);
     return $this->store->forget($key);
 }
 /**
  * Flushes traces of records related to the provided keywords, otherwise proceeds to regular flush() method.
  */
 public function flush()
 {
     if (!empty($this->keywords)) {
         $flushedKeys = $this->forgetKeywordIndex($this->keywords);
         $affectedKeywords = $this->forgetInverseIndex($flushedKeys);
         foreach ($flushedKeys as $flushedKey) {
             // Set all affected keywords as old keywords and request
             // empty new keywords to remove the flushed key from other indices as well.
             $this->determineKeywordsState($flushedKey, [], $affectedKeywords);
             $this->updateKeywordIndex($flushedKey);
             parent::forget($flushedKey);
         }
     } else {
         parent::flush();
     }
     if (!$this->operatingOnKeywords()) {
         $this->resetCurrentKeywords();
     }
 }
Ejemplo n.º 12
0
 /**
  * Remove an item from the cache.
  *
  * @param  string $key
  *
  * @return bool
  */
 public function forget($key)
 {
     return $this->enabled ? $this->cache->forget($key) : false;
 }
 /**
  * deleteCachedSiteInstanceRoutes
  *
  * @param string $siteKey key of site
  *
  * @return void
  */
 public function deleteCachedSiteInstanceRoutes($siteKey)
 {
     $keyString = $this->getSiteCacheKeyString($siteKey);
     $this->cache->forget($keyString);
 }