Skip to content

Commit

Permalink
Add new filter to allow site owner to specify cache locking method.
Browse files Browse the repository at this point in the history
  • Loading branch information
raamdev committed Dec 27, 2014
1 parent c79e423 commit 9aacf8b
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions quick-cache-pro/includes/share.php
Expand Up @@ -1807,12 +1807,18 @@ public function cache_lock()
if(!($wp_config_file = $this->find_wp_config_file()))
throw new \exception(__('Unable to find the wp-config.php file.', $this->text_domain));

if($this->function_is_possible('sem_get'))
if(($ipc_key = ftok($wp_config_file, 'w')))
if(($resource = sem_get($ipc_key, 1)) && sem_acquire($resource))
return array('type' => 'sem', 'resource' => $resource);
$locking_method = apply_filters('quick_cache_cache_locking_method', 'flock');

// Use `flock()` as a decent fallback when `sem_get()` is not possible.
if(!in_array($locking_method, array('flock', 'sem')))
$locking_method = 'flock';

if($locking_method === 'sem')
if($this->function_is_possible('sem_get'))
if(($ipc_key = ftok($wp_config_file, 'w')))
if(($resource = sem_get($ipc_key, 1)) && sem_acquire($resource))
return array('type' => 'sem', 'resource' => $resource);

// Use `flock()` as a decent fallback when `sem_get()` is not not forced or is not possible.

if(!($tmp_dir = $this->get_tmp_dir()))
throw new \exception(__('No writable tmp directory.', $this->text_domain));
Expand Down

0 comments on commit 9aacf8b

Please sign in to comment.