php - How to update the cache value when database has change value of same data which is stored in cache -


if using laravel 4.2 caching mechanism bellow.

$users = db::table('users')->remember(10)->get(); 

as understand cache mechanism query execute one's , story it's value cache , return data cache upto 10 minutes.

but problem one's query executed , data stored it's cache inbetween user table updates it's value how may check , update cache value can updated data.

any 1 have idea suggestion please let me know...?

if using supported cache driver, can add tags caches:

$users = db::table('users')->cachetags(array('people', 'authors'))->remember(10)->get(); 

then when value updated, can flush cached values under tag. example, in user model add:

public function save(array $options = []) {     $result = parent::save($options);      if ($result) {         cache::tags(array('people', 'authors'))->flush();     }      return $result; } 

Comments

Popular posts from this blog

python - pip install -U PySide error -

arrays - C++ error: a brace-enclosed initializer is not allowed here before ‘{’ token -

cytoscape.js - How to add nodes to Dagre layout with Cytoscape -