Elgg\Cache\Pool::put PHP Méthode

put() public méthode

This is useful when the value was calculated by some out-of-band means. For example, when a list of rows is fetched from the database, you can prime the cache for each individual result.
public put ( string | integer $key, mixed $value ) : void
$key string | integer A plain string ID for the cache entry
$value mixed The cache value
Résultat void
    public function put($key, $value);

Usage Example

Exemple #1
0
 /**
  * Load entire datalist in memory.
  * 
  * This could cause OOM problems if the datalists table is large.
  * 
  * @todo make a list of datalists that we want to get in one grab
  * 
  * @return array
  * @access private
  */
 function loadAll()
 {
     $result = $this->db->getData("SELECT * FROM {$this->table}");
     $map = array();
     if (is_array($result)) {
         foreach ($result as $row) {
             $map[$row->name] = $row->value;
             $this->cache->put($row->name, $row->value);
         }
     }
     return $map;
 }
All Usage Examples Of Elgg\Cache\Pool::put