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

[Compatibility] Add hash expiration - HEXPIRE, HPEXPIRE, HEXPIREAT, HPEXPIREAT, HTTL, HPTTL, HEXPIRETIME, HPEXPIRETIME, HPERSIST and HCOLLECT #864

Open
wants to merge 35 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
4c955b3
WIP of HEXPIRE
Vijay-Nirmal Dec 9, 2024
e7695e2
WIP of EXPIRE
Vijay-Nirmal Dec 9, 2024
06e2d4c
Initial impelementation of HEXIRE and family
Vijay-Nirmal Dec 9, 2024
722a134
Merged latest
Vijay-Nirmal Dec 9, 2024
35e385f
Added more test cases
Vijay-Nirmal Dec 11, 2024
c27de0d
Handling serialization and Deserialization
Vijay-Nirmal Dec 11, 2024
a650ba9
Added LTM test cases
Vijay-Nirmal Dec 11, 2024
052fc06
Merged latest
Vijay-Nirmal Dec 11, 2024
968e5a3
Added docs
Vijay-Nirmal Dec 12, 2024
4a7a711
Added HCOLLECT and ACL, Slot verification tests
Vijay-Nirmal Dec 12, 2024
f31633c
Add a background task to call HCOLLECT to delete expired items
Vijay-Nirmal Dec 12, 2024
006a202
Code format fix
Vijay-Nirmal Dec 12, 2024
a1c5641
Merge branch 'main' into new/HEXPIRE-command
Vijay-Nirmal Dec 12, 2024
f8628f1
Fixed creation of empty object
Vijay-Nirmal Dec 12, 2024
85527f2
Finial commit before review comment fixes, hopefully
Vijay-Nirmal Dec 12, 2024
14fa5ba
This time for sure, this is the last commit before review comments
Vijay-Nirmal Dec 12, 2024
f0ef454
Fixed code format issue
Vijay-Nirmal Dec 12, 2024
7d7965b
Trying to fix test failure in pipeline (not happening in local)
Vijay-Nirmal Dec 12, 2024
29bfc24
Merge branch 'main' into new/HEXPIRE-command
Vijay-Nirmal Dec 13, 2024
fa20261
Merged latest
Vijay-Nirmal Dec 13, 2024
0b96546
Removed AsEnumerable to remove the allocation
Vijay-Nirmal Dec 13, 2024
23f5ea2
Fixed missed TODO
Vijay-Nirmal Dec 13, 2024
84973ff
Merge branch 'main' into new/HEXPIRE-command
Vijay-Nirmal Dec 14, 2024
7e71c9b
Review comment fixes
Vijay-Nirmal Dec 14, 2024
6d01ad8
Merge branch 'new/HEXPIRE-command' of https://github.com/Vijay-Nirmal…
Vijay-Nirmal Dec 14, 2024
764a7b4
Review comment fixes
Vijay-Nirmal Dec 14, 2024
dc69d98
Test fix, maybe
Vijay-Nirmal Dec 14, 2024
1cd8c28
Merged latest
Vijay-Nirmal Dec 17, 2024
444fdf6
Review command fix
Vijay-Nirmal Dec 17, 2024
e99e19d
Fixed test failure
Vijay-Nirmal Dec 17, 2024
569bc45
Merged latest
Vijay-Nirmal Dec 18, 2024
8576434
Merge branch 'main' into new/HEXPIRE-command
Vijay-Nirmal Dec 19, 2024
2f07f2d
Merge branch 'main' into new/HEXPIRE-command
Vijay-Nirmal Dec 19, 2024
6c08adb
Test fix
Vijay-Nirmal Dec 19, 2024
b1c4bbd
Test fix
Vijay-Nirmal Dec 19, 2024
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
501 changes: 501 additions & 0 deletions libs/resources/RespCommandsDocs.json

Large diffs are not rendered by default.

225 changes: 225 additions & 0 deletions libs/resources/RespCommandsInfo.json
Original file line number Diff line number Diff line change
Expand Up @@ -1596,6 +1596,81 @@
}
]
},
{
"Command": "HEXPIRE",
"Name": "HEXPIRE",
"Arity": -6,
"Flags": "DenyOom, Fast, Write",
"FirstKey": 1,
"LastKey": 1,
"Step": 1,
"AclCategories": "Hash, Fast, Write",
"KeySpecifications": [
{
"BeginSearch": {
"TypeDiscriminator": "BeginSearchIndex",
"Index": 1
},
"FindKeys": {
"TypeDiscriminator": "FindKeysRange",
"LastKey": 0,
"KeyStep": 1,
"Limit": 0
},
"Flags": "RW, Update"
}
]
},
{
"Command": "HEXPIREAT",
"Name": "HEXPIREAT",
"Arity": -6,
"Flags": "DenyOom, Fast, Write",
"FirstKey": 1,
"LastKey": 1,
"Step": 1,
"AclCategories": "Hash, Fast, Write",
"KeySpecifications": [
{
"BeginSearch": {
"TypeDiscriminator": "BeginSearchIndex",
"Index": 1
},
"FindKeys": {
"TypeDiscriminator": "FindKeysRange",
"LastKey": 0,
"KeyStep": 1,
"Limit": 0
},
"Flags": "RW, Update"
}
]
},
{
"Command": "HEXPIRETIME",
"Name": "HEXPIRETIME",
"Arity": -5,
"Flags": "Fast, ReadOnly",
"FirstKey": 1,
"LastKey": 1,
"Step": 1,
"AclCategories": "Hash, Fast, Read",
"KeySpecifications": [
{
"BeginSearch": {
"TypeDiscriminator": "BeginSearchIndex",
"Index": 1
},
"FindKeys": {
"TypeDiscriminator": "FindKeysRange",
"LastKey": 0,
"KeyStep": 1,
"Limit": 0
},
"Flags": "RO, Access"
}
]
},
{
"Command": "HGET",
"Name": "HGET",
Expand Down Expand Up @@ -1802,6 +1877,131 @@
}
]
},
{
"Command": "HPERSIST",
"Name": "HPERSIST",
"Arity": -5,
"Flags": "Fast, Write",
"FirstKey": 1,
"LastKey": 1,
"Step": 1,
"AclCategories": "Hash, Fast, Write",
"KeySpecifications": [
{
"BeginSearch": {
"TypeDiscriminator": "BeginSearchIndex",
"Index": 1
},
"FindKeys": {
"TypeDiscriminator": "FindKeysRange",
"LastKey": 0,
"KeyStep": 1,
"Limit": 0
},
"Flags": "RW, Update"
}
]
},
{
"Command": "HPEXPIRE",
"Name": "HPEXPIRE",
"Arity": -6,
"Flags": "DenyOom, Fast, Write",
"FirstKey": 1,
"LastKey": 1,
"Step": 1,
"AclCategories": "Hash, Fast, Write",
"KeySpecifications": [
{
"BeginSearch": {
"TypeDiscriminator": "BeginSearchIndex",
"Index": 1
},
"FindKeys": {
"TypeDiscriminator": "FindKeysRange",
"LastKey": 0,
"KeyStep": 1,
"Limit": 0
},
"Flags": "RW, Update"
}
]
},
{
"Command": "HPEXPIREAT",
"Name": "HPEXPIREAT",
"Arity": -6,
"Flags": "DenyOom, Fast, Write",
"FirstKey": 1,
"LastKey": 1,
"Step": 1,
"AclCategories": "Hash, Fast, Write",
"KeySpecifications": [
{
"BeginSearch": {
"TypeDiscriminator": "BeginSearchIndex",
"Index": 1
},
"FindKeys": {
"TypeDiscriminator": "FindKeysRange",
"LastKey": 0,
"KeyStep": 1,
"Limit": 0
},
"Flags": "RW, Update"
}
]
},
{
"Command": "HPEXPIRETIME",
"Name": "HPEXPIRETIME",
"Arity": -5,
"Flags": "Fast, ReadOnly",
"FirstKey": 1,
"LastKey": 1,
"Step": 1,
"AclCategories": "Hash, Fast, Read",
"KeySpecifications": [
{
"BeginSearch": {
"TypeDiscriminator": "BeginSearchIndex",
"Index": 1
},
"FindKeys": {
"TypeDiscriminator": "FindKeysRange",
"LastKey": 0,
"KeyStep": 1,
"Limit": 0
},
"Flags": "RO, Access"
}
]
},
{
"Command": "HPTTL",
"Name": "HPTTL",
"Arity": -5,
"Flags": "Fast, ReadOnly",
"FirstKey": 1,
"LastKey": 1,
"Step": 1,
"AclCategories": "Hash, Fast, Read",
"KeySpecifications": [
{
"BeginSearch": {
"TypeDiscriminator": "BeginSearchIndex",
"Index": 1
},
"FindKeys": {
"TypeDiscriminator": "FindKeysRange",
"LastKey": 0,
"KeyStep": 1,
"Limit": 0
},
"Flags": "RO, Access"
}
]
},
{
"Command": "HRANDFIELD",
"Name": "HRANDFIELD",
Expand Down Expand Up @@ -1933,6 +2133,31 @@
}
]
},
{
"Command": "HTTL",
"Name": "HTTL",
"Arity": -5,
"Flags": "Fast, ReadOnly",
"FirstKey": 1,
"LastKey": 1,
"Step": 1,
"AclCategories": "Hash, Fast, Read",
"KeySpecifications": [
{
"BeginSearch": {
"TypeDiscriminator": "BeginSearchIndex",
"Index": 1
},
"FindKeys": {
"TypeDiscriminator": "FindKeysRange",
"LastKey": 0,
"KeyStep": 1,
"Limit": 0
},
"Flags": "RO, Access"
}
]
},
{
"Command": "HVALS",
"Name": "HVALS",
Expand Down
12 changes: 12 additions & 0 deletions libs/server/API/GarnetApiObjectCommands.cs
Original file line number Diff line number Diff line change
Expand Up @@ -473,10 +473,22 @@ public GarnetStatus HashIncrement(byte[] key, ArgSlice input, out ObjectOutputHe
public GarnetStatus HashIncrement(byte[] key, ref ObjectInput input, ref GarnetObjectStoreOutput outputFooter)
=> storageSession.HashIncrement(key, ref input, ref outputFooter, ref objectContext);

/// <inheritdoc />
public GarnetStatus HashExpire(ArgSlice key, long expireAt, bool isMilliseconds, ExpireOption expireOption, ref ObjectInput input, ref GarnetObjectStoreOutput outputFooter)
=> storageSession.HashExpire(key, expireAt, isMilliseconds, expireOption, ref input, ref outputFooter, ref objectContext);

/// <inheritdoc />
public GarnetStatus HashPersist(ArgSlice key, ref ObjectInput input, ref GarnetObjectStoreOutput outputFooter)
=> storageSession.HashPersist(key, ref input, ref outputFooter, ref objectContext);

/// <inheritdoc />
public GarnetStatus HashScan(ArgSlice key, long cursor, string match, int count, out ArgSlice[] items)
=> storageSession.ObjectScan(GarnetObjectType.Hash, key, cursor, match, count, out items, ref objectContext);

/// <inheritdoc />
public GarnetStatus HashTimeToLive(ArgSlice key, bool isMilliseconds, bool isTimestamp, ref ObjectInput input, ref GarnetObjectStoreOutput outputFooter)
=> storageSession.HashTimeToLive(key, isMilliseconds, isTimestamp, ref input, ref outputFooter, ref objectContext);

#endregion
}

Expand Down
7 changes: 7 additions & 0 deletions libs/server/API/GarnetWatchApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -442,6 +442,13 @@ public GarnetStatus HashScan(ArgSlice key, long cursor, string match, int count,
return garnetApi.HashScan(key, cursor, match, count, out items);
}

/// <inheritdoc />
public GarnetStatus HashTimeToLive(ArgSlice key, bool isMilliseconds, bool isTimestamp, ref ObjectInput input, ref GarnetObjectStoreOutput outputFooter)
{
garnetApi.WATCH(key, StoreType.Object);
return garnetApi.HashTimeToLive(key, isMilliseconds, isTimestamp, ref input, ref outputFooter);
}

#endregion

#region Bitmap Methods
Expand Down
31 changes: 31 additions & 0 deletions libs/server/API/IGarnetApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -962,6 +962,26 @@ public interface IGarnetApi : IGarnetReadApi, IGarnetAdvancedApi
/// <returns></returns>
GarnetStatus HashIncrement(byte[] key, ref ObjectInput input, ref GarnetObjectStoreOutput outputFooter);

/// <summary>
/// Sets an expiration time on a hash field.
/// </summary>
/// <param name="key">The key of the hash.</param>
/// <param name="expireAt">The expiration time in Unix timestamp format.</param>
/// <param name="expireOption">The expiration option to apply.</param>
/// <param name="input">The input object containing additional parameters.</param>
/// <param name="outputFooter">The output object to store the result.</param>
/// <returns>The status of the operation.</returns>
GarnetStatus HashExpire(ArgSlice key, long expireAt, bool isMilliseconds, ExpireOption expireOption, ref ObjectInput input, ref GarnetObjectStoreOutput outputFooter);

/// <summary>
/// Persists the specified hash key, removing any expiration time set on it.
/// </summary>
/// <param name="key">The key of the hash to persist.</param>
/// <param name="input">The input object containing additional parameters.</param>
/// <param name="outputFooter">The output object to store the result.</param>
/// <returns>The status of the operation.</returns>
GarnetStatus HashPersist(ArgSlice key, ref ObjectInput input, ref GarnetObjectStoreOutput outputFooter);

#endregion

#region BitMaps Methods
Expand Down Expand Up @@ -1599,6 +1619,17 @@ public interface IGarnetReadApi
/// <returns></returns>
GarnetStatus HashScan(ArgSlice key, long cursor, string match, int count, out ArgSlice[] items);

/// <summary>
/// Returns the time to live for a hash key.
/// </summary>
/// <param name="key">The key of the hash.</param>
/// <param name="isMilliseconds">Indicates if the time to live is in milliseconds.</param>
/// <param name="isTimestamp">Indicates if the time to live is a timestamp.</param>
/// <param name="input">The input object containing additional parameters.</param>
/// <param name="outputFooter">The output object to store the result.</param>
/// <returns>The status of the operation.</returns>
GarnetStatus HashTimeToLive(ArgSlice key, bool isMilliseconds, bool isTimestamp, ref ObjectInput input, ref GarnetObjectStoreOutput outputFooter);

#endregion

#region Bitmaps Methods
Expand Down
Loading
Loading