public function set($module, $key, $value)
{
$valueToStore = serialize($value);
$this->database->execute('INSERT INTO modules_settings(module, name, value)
VALUES(?, ?, ?)
ON DUPLICATE KEY UPDATE value = ?', array($module, $key, $valueToStore, $valueToStore));
/*
* Instead of invalidating the cache, we could also fetch existing
* settings, update them & re-store them to cache. That would save
* us the next query to repopulate the cache.
* However, there could be race conditions where 2 concurrent
* requests write at the same time and one ends up overwriting the
* other (unless we do a CAS, but PSR-6 doesn't support that)
* Clearing cache will be safe: in the case of concurrent requests
* & cache being regenerated while the other is being saved, it will
* be cleared again after saving the new setting!
*/
$this->cache->deleteItems(array('settings'));
}