Skip to content

Commit

Permalink
Maintain ttl on update (#340)
Browse files Browse the repository at this point in the history
  • Loading branch information
zulander1 authored Apr 14, 2023
1 parent dc2e33e commit d6982ee
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/Redis.OM/Scripts.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,12 @@ local second_op
/// Unlinks a JSON object and sets the key again with a fresh new JSON object.
/// </summary>
internal const string UnlinkAndSendJson = @"
local expiry = tonumber(redis.call('PTTL', KEYS[1]))
redis.call('UNLINK', KEYS[1])
redis.call('JSON.SET', KEYS[1], '.', ARGV[1])
if expiry > 0 then
redis.call('PEXPIRE', KEYS[1], expiry)
end
return 0
";

Expand All @@ -100,8 +104,8 @@ local second_op
redis.call('HSET', KEYS[1], unpack(hashArgs))
if expiry > 0 then
redis.call('PEXPIRE', KEYS[1], expiry)
end
return 1
end
return 1
end
return 0
";
Expand Down Expand Up @@ -151,7 +155,7 @@ local second_op
/// <summary>
/// The scripts.
/// </summary>
internal static readonly Dictionary<string, string> ScriptCollection = new ()
internal static readonly Dictionary<string, string> ScriptCollection = new()
{
{ nameof(JsonDiffResolution), JsonDiffResolution },
{ nameof(HashDiffResolution), HashDiffResolution },
Expand All @@ -166,6 +170,6 @@ local second_op
/// <summary>
/// Gets or sets collection of SHAs.
/// </summary>
internal static ConcurrentDictionary<string, string> ShaCollection { get; set; } = new ();
internal static ConcurrentDictionary<string, string> ShaCollection { get; set; } = new();
}
}
}

0 comments on commit d6982ee

Please sign in to comment.