Commit a335a78a authored by Marc Gravell's avatar Marc Gravell

Detect changes to the run_id when connecting; if observed, reset the script cache

parent bb3b5e69
...@@ -101,6 +101,23 @@ Task<string> IRedisAsync.ClientGetNameAsync(CommandFlags flags) ...@@ -101,6 +101,23 @@ Task<string> IRedisAsync.ClientGetNameAsync(CommandFlags flags)
partial class ServerEndPoint partial class ServerEndPoint
{ {
private string runId;
internal string RunId
{
get { return runId; }
set
{
if(value != runId) // we only care about changes
{
// if we had an old run-id, and it has changed, then the
// server has been restarted; which means the script cache
// is toast
if(runId != null) FlushScriptCache();
runId = value;
}
}
}
internal void SimulateConnectionFailure() internal void SimulateConnectionFailure()
{ {
var tmp = interactive; var tmp = interactive;
......
...@@ -538,6 +538,10 @@ protected override bool SetResultCore(PhysicalConnection connection, Message mes ...@@ -538,6 +538,10 @@ protected override bool SetResultCore(PhysicalConnection connection, Message mes
break; break;
} }
} }
else if((val = Extract(line, "run_id:")) != null)
{
server.RunId = val;
}
} }
} }
} }
...@@ -1037,7 +1041,7 @@ public override bool SetResult(PhysicalConnection connection, Message message, R ...@@ -1037,7 +1041,7 @@ public override bool SetResult(PhysicalConnection connection, Message message, R
{ {
if (result.Type == ResultType.Error && result.AssertStarts(NOSCRIPT)) if (result.Type == ResultType.Error && result.AssertStarts(NOSCRIPT))
{ // scripts are not flushed individually, so assume the entire script cache is toast ("SCRIPT FLUSH") { // scripts are not flushed individually, so assume the entire script cache is toast ("SCRIPT FLUSH")
connection.Bridge.ServerEndPoint.FlushScripts(); connection.Bridge.ServerEndPoint.FlushScriptCache();
message.SetScriptUnavailable(); message.SetScriptUnavailable();
} }
// and apply usual processing for the rest // and apply usual processing for the rest
......
...@@ -319,7 +319,7 @@ internal Task Close() ...@@ -319,7 +319,7 @@ internal Task Close()
return result; return result;
} }
internal void FlushScripts() internal void FlushScriptCache()
{ {
lock (knownScripts) lock (knownScripts)
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment