Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

query cache triggers - add set func variable #8848

Merged
merged 1 commit into from Oct 31, 2019
Merged
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.

Always

Just for now

@@ -54,11 +54,13 @@

);

$setFunc = 'memc_set';

$TRIGGER_TYPES = array('INSERT', 'UPDATE', 'DELETE');

$SPECIAL_TRIGGERS = array(
"invalid_session/INSERT" => "DO memc_set(concat('invalid_session_', IF(NEW.ks IS NULL, '', NEW.ks)), 1, IF(NEW.ks_valid_until IS NULL, 0, UNIX_TIMESTAMP(NEW.ks_valid_until) + 600));",
"file_sync/INSERT" => "IF (NEW.original) THEN DO memc_set(concat('fileSyncMaxId-dc', NEW.dc), NEW.id); END IF;",
"invalid_session/INSERT" => "DO $setFunc(concat('invalid_session_', IF(NEW.ks IS NULL, '', NEW.ks)), 1, IF(NEW.ks_valid_until IS NULL, 0, UNIX_TIMESTAMP(NEW.ks_valid_until) + 600));",
"file_sync/INSERT" => "IF (NEW.original) THEN DO $setFunc(concat('fileSyncMaxId-dc', NEW.dc), NEW.id, 0); END IF;",
);

function generateInvalidationKeyCode($invalidationKey)
@@ -213,7 +215,7 @@ function compareTriggerBodies($body1, $body2)

function buildTriggerBody($invalidationKey, $triggerType)
{
global $SPECIAL_TRIGGERS;
global $SPECIAL_TRIGGERS, $setFunc;

$tableName = $invalidationKey['table'];
$triggerBody = array();
@@ -234,7 +236,7 @@ function buildTriggerBody($invalidationKey, $triggerType)
}
$curKey = 'concat(' . implode(', ', $curKey) . ')';

$memSetCmd = "memc_set($curKey, UNIX_TIMESTAMP(SYSDATE()), 90000)";
$memSetCmd = "$setFunc($curKey, UNIX_TIMESTAMP(SYSDATE()), 90000)";
$memSetCmdOld = str_replace('@OBJ@', 'OLD', $memSetCmd);
$memSetCmdNew = str_replace('@OBJ@', 'NEW', $memSetCmd);

@@ -312,7 +314,7 @@ function buildTriggerBody($invalidationKey, $triggerType)

// Make sure 'Memcached Functions for MySQL' is installed
mysqli_select_db($link,'mysql') or die("Error: Could not select 'mysql' database\n");
$query = "SELECT * FROM func WHERE name='memc_server_count'";
$query = "SELECT * FROM func WHERE name='$setFunc'";
$result = mysqli_query($link,$query) or die('Error: Select from func table query failed: ' . mysqli_error($link) . "\n");

if (!mysqli_fetch_array($result, MYSQLI_ASSOC))
@@ -326,18 +328,18 @@ function buildTriggerBody($invalidationKey, $triggerType)
mysqli_select_db($link,'kaltura') or die("Error: Could not select 'kaltura' database\n");

// Make sure the memcache server is configured
$query = "SELECT memc_server_count()";
$result = mysqli_query($link,$query) or die('Error: Select memc_server_count query failed: ' . mysqli_error($link) . "\n");
$query = "SELECT $setFunc('test', 'test', 10)";
$result = mysqli_query($link,$query) or die('Error: Select memcache set query failed: ' . mysqli_error($link) . "\n");

$line = mysqli_fetch_array($result, MYSQLI_NUM);
if (!$line)
{
die("Unexpected: memc_server_count returned nothing\n");
die("Unexpected: $setFunc returned nothing\n");
}

if ($line[0] <= 0)
{
die("Error: Memcached server not configured\n");
die("Error: Memcached set failed\n");
}

mysqli_free_result($result);
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.