Skip to content

Maintain ttl on update #340

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

Merged
merged 8 commits into from
Apr 14, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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();
}
}
}