本文整理汇总了PHP中Unlock函数的典型用法代码示例。如果您正苦于以下问题:PHP Unlock函数的具体用法?PHP Unlock怎么用?PHP Unlock使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Unlock函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: PSS_GetCacheEntry
/**
* Get a cached test result
*/
function PSS_GetCacheEntry($url)
{
$id = null;
$cache_lock = Lock("PSS Cache");
if (isset($cache_lock)) {
if (is_file('./tmp/pss.cache')) {
$cache = json_decode(file_get_contents('./tmp/pss.cache'), true);
// delete stale cache entries
$now = time();
$dirty = false;
foreach ($cache as $cache_key => &$cache_entry) {
if ($cache_entry['expires'] < $now) {
$dirty = true;
unset($cache[$cache_key]);
}
}
if ($dirty) {
file_put_contents('./tmp/pss.cache', json_encode($cache));
}
$key = md5($url);
if (array_key_exists($key, $cache) && array_key_exists('id', $cache[$key])) {
$id = $cache[$key]['id'];
}
}
Unlock($cache_lock);
}
return $id;
}
示例2: Unlock
if ($results[0] >= $GLOBALS["spdrefresh"]) {
if (Lock("SPEED:{$info_hash}")) {
@runSpeed($info_hash, $results[0]);
Unlock("SPEED:{$info_hash}");
}
}
}
if ($GLOBALS["doavg"] && !$GLOBALS["heavyload"]) {
// Once every minute or so, we run the speed update checker.
$query = @mysql_query("SELECT UNIX_TIMESTAMP() - lastAvgCycle FROM summary WHERE info_hash=\"{$info_hash}\"");
$results = mysql_fetch_row($query);
if ($results[0] >= $GLOBALS["avgrefresh"]) {
if (Lock("AVG:{$info_hash}")) {
@quickQuery("UPDATE summary SET lastAvgCycle = UNIX_TIMESTAMP() WHERE info_hash=\"{$info_hash}\"");
@runAvg($info_hash);
Unlock("AVG:{$info_hash}");
}
}
}
/*
* Under heavy loads, this will lighten the load slightly... very slightly...
*/
if ($GLOBALS["heavyload"]) {
if (mt_rand(1, 10) == 4) {
trashCollector($info_hash, $report_interval);
}
} else {
trashCollector($info_hash, $report_interval);
}
/*
* Finally, it's time to do stuff to the summary table.
示例3: CheckIp
/**
* For each IP/Installer pair, keep track of the last 4 checks and if they
* were within the last hour fail the request.
*
* @param mixed $installer
*/
function CheckIp($installer)
{
$ok = true;
$ip = $_SERVER["REMOTE_ADDR"];
if (isset($ip) && strlen($ip)) {
$lock = Lock("Installers", true, 5);
if ($lock) {
$now = time();
$file = "./tmp/installers.dat";
if (gz_is_file($file)) {
$history = json_decode(gz_file_get_contents($file), true);
}
if (!isset($history) || !is_array($history)) {
$history = array();
}
if (isset($history[$ip])) {
if (isset($history[$ip][$installer])) {
$history[$ip][$installer][] = $now;
if (count($history[$ip][$installer]) > 10) {
array_shift($history[$ip][$installer]);
}
if (isset($history[$ip]["last-{$installer}"]) && $now - $history[$ip]["last-{$installer}"] < 3600) {
$count = 0;
foreach ($history[$ip][$installer] as $time) {
if ($now - $time < 3600) {
$count++;
}
}
if ($count > 4) {
$ok = false;
}
}
} else {
$history[$ip][$installer] = array($now);
}
} else {
$history[$ip] = array($installer => array($now));
}
$history[$ip]['last'] = $now;
if ($ok) {
$history[$ip]["last-{$installer}"] = $now;
}
// prune any agents that haven't connected in 7 days
foreach ($history as $agent => $info) {
if ($now - $info['last'] > 604800) {
unset($history[$agent]);
}
}
gz_file_put_contents($file, json_encode($history));
Unlock($lock);
}
}
return $ok;
}
示例4: explode
}
// Header is most likely already: 200 Ok
//error_log("Send length: $xmitbytes == ".strlen($xmit));
if (isset($_GET["ranges"])) {
$myxmit = "";
$ranges = explode(",", $_GET["ranges"]);
foreach ($ranges as $blocks) {
$startstop = explode("-", $blocks);
if (!is_numeric($startstop[0]) || !is_numeric($startstop[1])) {
reject("400 Bad Request");
}
if (isset($startstop[2])) {
reject("400 Bad Request");
}
$start = $startstop[0];
$stop = $startstop[1];
if ($start > $stop) {
reject("400 Bad Request");
}
$myxmit .= substr($xmit, $start, $stop - $start + 1);
}
header("Content-Length: " . strlen($myxmit));
mysql_query("UPDATE " . $prefix . "speedlimit SET uploaded=uploaded+" . strlen($myxmit));
echo $myxmit;
} else {
mysql_query("UPDATE " . $prefix . "speedlimit SET uploaded=uploaded+{$xmitbytes}");
header("Content-Length: {$xmitbytes}");
echo $xmit;
}
Unlock("WebSeed--{$lockno}");
exit;
示例5: ValidateKey
/**
* See if we are requiring key validation and if so, enforce the restrictions
*
* @param mixed $test
* @param mixed $error
*/
function ValidateKey(&$test, &$error, $key = null)
{
global $admin;
// load the secret key (if there is one)
$secret = '';
$keys = parse_ini_file('./settings/keys.ini', true);
if ($keys && isset($keys['server']) && isset($keys['server']['secret'])) {
$secret = trim($keys['server']['secret']);
}
if (strlen($secret)) {
// ok, we require key validation, see if they have an hmac (user with form)
// or API key
if (!isset($key) && isset($test['vh']) && strlen($test['vh'])) {
// validate the hash
$hashStr = $secret;
$hashStr .= $_SERVER['HTTP_USER_AGENT'];
$hashStr .= $test['owner'];
$hashStr .= $test['vd'];
$hmac = sha1($hashStr);
// check the elapsed time since the hmac was issued
$now = time();
$origTime = strtotime($test['vd']);
$elapsed = abs($now - $origTime);
if ($hmac != $test['vh'] || $elapsed > 86400) {
$error = 'Your test request could not be validated (this can happen if you leave the browser window open for over a day before submitting a test). Please try submitting it again.';
}
} elseif (isset($key) || isset($test['key']) && strlen($test['key'])) {
if (isset($test['key']) && strlen($test['key']) && !isset($key)) {
$key = $test['key'];
}
// see if it was an auto-provisioned key
if (preg_match('/^(?P<prefix>[0-9A-Za-z]+)\\.(?P<key>[0-9A-Za-z]+)$/', $key, $matches)) {
$prefix = $matches['prefix'];
$db = new SQLite3(__DIR__ . "/dat/{$prefix}_api_keys.db");
$k = $db->escapeString($matches['key']);
$info = $db->querySingle("SELECT key_limit FROM keys WHERE key='{$k}'", true);
$db->close();
if (isset($info) && is_array($info) && isset($info['key_limit'])) {
$keys[$key] = array('limit' => $info['key_limit']);
}
}
// validate their API key and enforce any rate limits
if (array_key_exists($key, $keys)) {
if (array_key_exists('default location', $keys[$key]) && strlen($keys[$key]['default location']) && !strlen($test['location'])) {
$test['location'] = $keys[$key]['default location'];
}
if (isset($keys[$key]['priority'])) {
$test['priority'] = $keys[$key]['priority'];
}
if (isset($keys[$key]['limit'])) {
$limit = (int) $keys[$key]['limit'];
// update the number of tests they have submitted today
if (!is_dir('./dat')) {
mkdir('./dat', 0777, true);
}
$lock = Lock("API Keys");
if (isset($lock)) {
$keyfile = './dat/keys_' . gmdate('Ymd') . '.dat';
$usage = null;
if (is_file($keyfile)) {
$usage = json_decode(file_get_contents($keyfile), true);
}
if (!isset($usage)) {
$usage = array();
}
if (isset($usage[$key])) {
$used = (int) $usage[$key];
} else {
$used = 0;
}
$runcount = max(1, $test['runs']);
if (!$test['fvonly']) {
$runcount *= 2;
}
if ($limit > 0) {
if ($used + $runcount <= $limit) {
$used += $runcount;
$usage[$key] = $used;
} else {
$error = 'The test request will exceed the daily test limit for the given API key';
}
} else {
$used += $runcount;
$usage[$key] = $used;
}
if (!strlen($error)) {
file_put_contents($keyfile, json_encode($usage));
}
Unlock($lock);
}
}
// check to see if we need to limit queue lengths from this API key
if ($keys[$key]['queue_limit']) {
$test['queue_limit'] = $keys[$key]['queue_limit'];
//.........这里部分代码省略.........
示例6: unset
unset($tests);
}
}
}
}
// Render the video
if (isset($tests) && count($tests)) {
$lock = Lock("video-{$videoId}", false, 600);
if ($lock) {
RenderVideo($tests);
if (is_file("{$videoPath}/render.mp4")) {
rename("{$videoPath}/render.mp4", "{$videoPath}/video.mp4");
}
$ini = 'completed=' . gmdate('c') . "\r\n";
file_put_contents("{$videoPath}/video.ini", $ini);
Unlock($lock);
}
}
$elapsed = microtime(true) - $start;
//echo number_format($elapsed, 3) . " seconds";
function RenderVideo(&$tests)
{
global $width, $height, $maxAspectRatio, $videoExtendTime, $biggestThumbnail, $fps, $labelHeight, $timeHeight, $rowPadding, $speed, $fractionTime;
// adjust the label sizes if we have a LOT of tests
$scale = 1;
$count = count($tests);
if ($count > 49) {
$scale = 0;
} elseif ($count > 36) {
$scale = 0.5;
} elseif ($count > 25) {
示例7: CheckCron
/**
* Send a quick http request locally if we need to process cron events (to each of the cron entry points)
*
* This only runs events on 15-minute intervals and tries to keep it close to the clock increments (00, 15, 30, 45)
*
*/
function CheckCron()
{
// open and lock the cron job file - abandon quickly if we can't get a lock
$should_run = false;
$minutes15 = false;
$minutes60 = false;
$cron_lock = Lock("Cron Check", false, 1200);
if (isset($cron_lock)) {
$last_run = 0;
if (is_file('./tmp/wpt_cron.dat')) {
$last_run = file_get_contents('./tmp/wpt_cron.dat');
}
$now = time();
$elapsed = $now - $last_run;
if (!$last_run) {
$should_run = true;
$minutes15 = true;
$minutes60 = true;
} elseif ($elapsed > 120) {
if ($elapsed > 1200) {
// if it has been over 20 minutes, run regardless of the wall-clock time
$should_run = true;
} else {
$minute = gmdate('i', $now) % 5;
if ($minute < 2) {
$should_run = true;
$minute = gmdate('i', $now) % 15;
if ($minute < 2) {
$minutes15 = true;
}
$minute = gmdate('i', $now) % 60;
if ($minute < 2) {
$minutes60 = true;
}
}
}
}
if ($should_run) {
file_put_contents('./tmp/wpt_cron.dat', $now);
}
Unlock($cron_lock);
}
// send the cron requests
if ($should_run) {
if (is_file('./settings/benchmarks/benchmarks.txt') && is_file('./benchmarks/cron.php')) {
SendAsyncRequest('/benchmarks/cron.php');
}
SendAsyncRequest('/cron/5min.php');
if (is_file('./jpeginfo/cleanup.php')) {
SendAsyncRequest('/jpeginfo/cleanup.php');
}
if ($minutes15) {
SendAsyncRequest('/cron/15min.php');
}
if ($minutes60) {
SendAsyncRequest('/cron/hourly.php');
}
}
}
示例8: ProcessBenchmark
/**
* Do all of the processing for a given benchmark
*
* @param mixed $benchmark
*/
function ProcessBenchmark($benchmark)
{
global $logFile;
$lock = Lock("Benchmark {$benchmark} Cron", false, 86400);
if (isset($lock)) {
logMsg("Processing benchmark '{$benchmark}'", "./log/{$logFile}", true);
$options = array();
if (include "./settings/benchmarks/{$benchmark}.php") {
if (!is_dir("./results/benchmarks/{$benchmark}")) {
mkdir("./results/benchmarks/{$benchmark}", 0777, true);
}
if (is_file("./results/benchmarks/{$benchmark}/state.json")) {
$state = json_decode(file_get_contents("./results/benchmarks/{$benchmark}/state.json"), true);
} else {
$state = array('running' => false, 'needs_aggregation' => true, 'runs' => array());
// build up a list of runs if we have data
if (is_dir("./results/benchmarks/{$benchmark}/data")) {
$files = scandir("./results/benchmarks/{$benchmark}/data");
$last_run = 0;
foreach ($files as $file) {
if (preg_match('/([0-9]+_[0-9]+)\\..*/', $file, $matches)) {
$UTC = new DateTimeZone('UTC');
$date = DateTime::createFromFormat('Ymd_Hi', $matches[1], $UTC);
$time = $date->getTimestamp();
$state['runs'][] = $time;
if ($time > $last_run) {
$last_run = $time;
}
}
}
if ($last_run) {
$state['last_run'] = $last_run;
}
}
file_put_contents("./results/benchmarks/{$benchmark}/state.json", json_encode($state));
}
if (!is_array($state)) {
$state = array('running' => false);
}
if (!array_key_exists('running', $state)) {
$state['running'] = false;
}
if (array_key_exists('running', $state)) {
CheckBenchmarkStatus($benchmark, $state);
// update the state between steps
file_put_contents("./results/benchmarks/{$benchmark}/state.json", json_encode($state));
} else {
$state['running'] = false;
}
if (!$state['running'] && (array_key_exists('runs', $state) && count($state['runs'])) && (!array_key_exists('needs_aggregation', $state) || $state['needs_aggregation'])) {
AggregateResults($benchmark, $state, $options);
file_put_contents("./results/benchmarks/{$benchmark}/state.json", json_encode($state));
}
// see if we need to kick off a new benchmark run
if (!$state['running'] && (!array_key_exists('tests', $state) || !is_array($state['tests']) || !count($state['tests']))) {
if (!array_key_exists('last_run', $state)) {
$state['last_run'] = 0;
}
$now = time();
if (call_user_func("{$benchmark}ShouldExecute", $state['last_run'], $now)) {
if (is_file("./log/{$logFile}")) {
unlink("./log/{$logFile}");
}
logMsg("Running benchmark '{$benchmark}'", "./log/{$logFile}", true);
if (SubmitBenchmark($configurations, $state, $benchmark)) {
$state['last_run'] = $now;
$state['running'] = true;
}
} else {
logMsg("Benchmark '{$benchmark}' does not need to be run", "./log/{$logFile}", true);
}
}
file_put_contents("./results/benchmarks/{$benchmark}/state.json", json_encode($state));
}
logMsg("Done Processing benchmark '{$benchmark}'", "./log/{$logFile}", true);
Unlock($lock);
}
}
示例9: EC2_GetRunningInstances
function EC2_GetRunningInstances()
{
$now = time();
$instances = array();
$key = GetSetting('ec2_key');
$secret = GetSetting('ec2_secret');
if ($key && $secret) {
$locations = EC2_GetAMILocations();
try {
$ec2 = \Aws\Ec2\Ec2Client::factory(array('key' => $key, 'secret' => $secret, 'region' => 'us-east-1'));
$regions = array();
$response = $ec2->describeRegions();
if (isset($response['Regions'])) {
foreach ($response['Regions'] as $region) {
$regions[] = $region['RegionName'];
}
}
} catch (\Aws\Ec2\Exception\Ec2Exception $e) {
$error = $e->getMessage();
EC2LogError("Listing running EC2 instances: {$error}");
}
if (isset($regions) && is_array($regions) && count($regions)) {
foreach ($regions as $region) {
try {
$ec2 = \Aws\Ec2\Ec2Client::factory(array('key' => $key, 'secret' => $secret, 'region' => $region));
$response = $ec2->describeInstances();
if (isset($response['Reservations'])) {
foreach ($response['Reservations'] as $reservation) {
foreach ($reservation['Instances'] as $instance) {
$wptLocations = null;
// See what locations are associated with the AMI
if (isset($instance['ImageId']) && isset($locations[$instance['ImageId']]['locations'])) {
$wptLocations = $locations[$instance['ImageId']]['locations'];
} elseif (isset($instance['Tags'])) {
// fall back to using tags to identify locations if they were set
foreach ($instance['Tags'] as $tag) {
if ($tag['Key'] == 'WPTLocations') {
$wptLocations = explode(',', $tag['Value']);
break;
}
}
}
if (isset($wptLocations)) {
$launchTime = strtotime($instance['LaunchTime']);
$elapsed = $now - $launchTime;
$state = $instance['State']['Code'];
$running = false;
if (is_numeric($state) && $state <= 16) {
$running = true;
}
$instances[] = array('region' => $region, 'id' => $instance['InstanceId'], 'ami' => $instance['ImageId'], 'state' => $state, 'launchTime' => $instance['LaunchTime'], 'launched' => $launchTime, 'runningTime' => $elapsed, 'locations' => $wptLocations, 'running' => $running);
}
}
}
}
} catch (\Aws\Ec2\Exception\Ec2Exception $e) {
$error = $e->getMessage();
EC2LogError("Listing running EC2 instances: {$error}");
}
}
}
}
// update the AMI counts we are tracking locally
if (count($instances)) {
$lock = Lock('ec2-instances', true, 120);
if ($lock) {
$amis = array();
foreach ($instances as $instance) {
if (isset($instance['ami']) && strlen($instance['ami']) && $instance['running']) {
if (!isset($amis[$instance['ami']])) {
$amis[$instance['ami']] = array('count' => 0);
}
$amis[$instance['ami']]['count']++;
}
}
file_put_contents('./tmp/ec2-instances.dat', json_encode($amis));
Unlock($lock);
}
}
return $instances;
}
示例10: delTree
delTree($archiveDir);
if (is_file($zipFile)) {
$bucket = "{$bucket_base}{$info['year']}_{$info['month']}_{$info['day']}_{$info['group']}{$suffix}";
logMessage("Uploading {$zipFile} to {$bucket}");
if (ArchiveFile($zipFile, $bucket)) {
logMessage("Archiving {$id} Complete");
file_put_contents("{$dir}/archive.dat", "{$download_path}{$bucket}/{$id}.zip");
} else {
logMessage("Archiving {$id} FAILED");
}
unlink($zipFile);
} else {
logMessage("Failed to combine files");
}
} else {
// Nothing to process, mark the group as done
file_put_contents("{$dir}/archive.dat", "");
file_put_contents("{$dir}/archive.dat.valid", "");
logMessage("{$id} - No tests to Archive");
}
} else {
logMessage("{$id} - Already Archived");
}
} else {
logMessage("{$id} - Tests still running");
}
Unlock($dir_lock);
} else {
logMessage("{$id} is already being processed");
}
});
示例11: Lock
$cron_lock = Lock("cron-60", false, 3600);
if (!isset($cron_lock)) {
exit(0);
}
header("Content-type: text/plain");
header("Cache-Control: no-cache, must-revalidate");
header("Expires: Sat, 26 Jul 1997 05:00:00 GMT");
echo "Running hourly cron...\n";
require_once './ec2/ec2.inc.php';
if (GetSetting('ec2_key')) {
EC2_DeleteOrphanedVolumes();
}
GitUpdate();
AgentUpdate();
ApkUpdate();
Unlock($cron_lock);
if (GetSetting('cron_archive')) {
chdir('./cli');
include 'archive.php';
}
echo "Done\n";
/**
* Automatically update from the git master (if configured)
*
*/
function GitUpdate()
{
if (GetSetting('gitUpdate')) {
echo "Updating from GitHub...\n";
echo shell_exec('git pull origin master');
}
示例12: UnLock
protected function UnLock()
{
if (isset($this->lock)) {
Unlock($this->lock);
}
}
示例13: TSViewCreate
function TSViewCreate($server, $tsview_name, &$metrics)
{
$needs_update = false;
if (!is_dir('./dat')) {
mkdir('./dat', 0777, true);
}
$def = './dat/tsview-' . sha1($tsview_name) . '.json';
$lock = Lock("TSView {$tsview_name}");
if (isset($lock)) {
if (is_file($def)) {
$current = json_decode(file_get_contents($def), true);
}
if (!isset($current) || !is_array($current)) {
$current = array();
}
foreach ($metrics as $metric => $x) {
if (!array_key_exists($metric, $current)) {
$needs_update = true;
$current[$metric] = 1;
}
}
if ($needs_update) {
$data = array('names' => array());
foreach ($current as $metric => $x) {
$data['names'][] = str_replace('.', '_', $metric);
}
$body = json_encode($data);
if (http_put_raw("{$server}{$tsview_name}", $body)) {
file_put_contents($def, json_encode($current));
}
}
Unlock($lock);
}
}
示例14: ValidateKey
/**
* See if we are requiring key validation and if so, enforce the restrictions
*
* @param mixed $test
* @param mixed $error
*/
function ValidateKey(&$test, &$error, $key = null)
{
global $admin;
// load the secret key (if there is one)
$secret = '';
$keys = parse_ini_file('./settings/keys.ini', true);
if ($keys && isset($keys['server']) && isset($keys['server']['secret'])) {
$secret = trim($keys['server']['secret']);
}
if (strlen($secret)) {
// ok, we require key validation, see if they have an hmac (user with form)
// or API key
if (!isset($key) && isset($test['vh']) && strlen($test['vh'])) {
// validate the hash
$hashStr = $secret;
$hashStr .= $_SERVER['HTTP_USER_AGENT'];
$hashStr .= $test['owner'];
$hashStr .= $test['vd'];
$hmac = sha1($hashStr);
// check the elapsed time since the hmac was issued
$now = time();
$origTime = strtotime($test['vd']);
$elapsed = abs($now - $origTime);
if ($hmac != $test['vh'] || $elapsed > 86400) {
$error = 'Your test request could not be validated (this can happen if you leave the browser window open for over a day before submitting a test). Please try submitting it again.';
}
} elseif (isset($key) || isset($test['key']) && strlen($test['key'])) {
if (isset($test['key']) && strlen($test['key']) && !isset($key)) {
$key = $test['key'];
}
// validate their API key and enforce any rate limits
if (array_key_exists($key, $keys)) {
if (array_key_exists('default location', $keys[$key]) && strlen($keys[$key]['default location']) && !strlen($test['location'])) {
$test['location'] = $keys[$key]['default location'];
}
if (isset($keys[$key]['priority'])) {
$test['priority'] = $keys[$key]['priority'];
}
if (isset($keys[$key]['limit'])) {
$limit = (int) $keys[$key]['limit'];
// update the number of tests they have submitted today
if (!is_dir('./dat')) {
mkdir('./dat', 0777, true);
}
$lock = Lock("API Keys");
if (isset($lock)) {
$keyfile = './dat/keys_' . gmdate('Ymd') . '.dat';
$usage = null;
if (is_file($keyfile)) {
$usage = json_decode(file_get_contents($keyfile), true);
}
if (!isset($usage)) {
$usage = array();
}
if (isset($usage[$key])) {
$used = (int) $usage[$key];
} else {
$used = 0;
}
$runcount = max(1, $test['runs']);
if (!$test['fvonly']) {
$runcount *= 2;
}
if ($limit > 0) {
if ($used + $runcount <= $limit) {
$used += $runcount;
$usage[$key] = $used;
} else {
$error = 'The test request will exceed the daily test limit for the given API key';
}
} else {
$used += $runcount;
$usage[$key] = $used;
}
if (!strlen($error)) {
file_put_contents($keyfile, json_encode($usage));
}
Unlock($lock);
}
}
// check to see if we need to limit queue lengths from this API key
if ($keys[$key]['queue_limit']) {
$test['queue_limit'] = $keys[$key]['queue_limit'];
}
} else {
$error = 'Invalid API Key';
}
if (!strlen($error)) {
global $usingAPI;
$usingAPI = true;
}
} elseif (!isset($admin) || !$admin) {
$error = 'An error occurred processing your request. Please reload the testing page and try submitting your test request again. (missing API key)';
}
//.........这里部分代码省略.........
示例15: SaveCachedDevToolsRequests
/**
* @param TestPaths $localPaths Paths for step or run to save the cached data
* @param array $requests The requests to save
* @param array $pageData The page data to save
* @param int $ver Cache version
*/
function SaveCachedDevToolsRequests($localPaths, &$requests, &$pageData, $ver)
{
$cacheFile = $localPaths->devtoolsRequestsCacheFile($ver);
$lock = Lock($cacheFile);
if (isset($lock)) {
if (gz_is_file($cacheFile)) {
$cache = json_decode(gz_file_get_contents($cacheFile), true);
}
if (!isset($cache) || !is_array($cache)) {
$cache = array();
}
$cache['requests'] = $requests;
$cache['pageData'] = $pageData;
gz_file_put_contents($cacheFile, json_encode($cache));
Unlock($lock);
}
}