Extend SugarDB Commands Using Lua Scripts (#155)

* Extend SugarDB by creating new commands using Lua - @kelvinmwinuka
This commit is contained in:
Kelvin Mwinuka
2024-12-12 09:50:43 +08:00
committed by GitHub
parent 3b15061dbc
commit 108bf97b4d
41 changed files with 9111 additions and 13573 deletions

View File

@@ -576,6 +576,7 @@ func Commands() []internal.Command {
Description: `(SADD key member [member...])
Add one or more members to the set. If the set does not exist, it's created.`,
Sync: true,
Type: "BUILT_IN",
KeyExtractionFunc: saddKeyFunc,
HandlerFunc: handleSADD,
},
@@ -585,6 +586,7 @@ Add one or more members to the set. If the set does not exist, it's created.`,
Categories: []string{constants.SetCategory, constants.WriteCategory, constants.FastCategory},
Description: "(SCARD key) Returns the cardinality of the set.",
Sync: false,
Type: "BUILT_IN",
KeyExtractionFunc: scardKeyFunc,
HandlerFunc: handleSCARD,
},
@@ -596,6 +598,7 @@ Add one or more members to the set. If the set does not exist, it's created.`,
If the first key provided is the only valid set, then this key's set will be returned as the result.
All keys that are non-existed or hold values that are not sets will be skipped.`,
Sync: false,
Type: "BUILT_IN",
KeyExtractionFunc: sdiffKeyFunc,
HandlerFunc: handleSDIFF,
},
@@ -606,6 +609,7 @@ All keys that are non-existed or hold values that are not sets will be skipped.`
Description: `(SDIFFSTORE destination key [key...]) Works the same as SDIFF but also stores the result at 'destination'.
Returns the cardinality of the new set.`,
Sync: true,
Type: "BUILT_IN",
KeyExtractionFunc: sdiffstoreKeyFunc,
HandlerFunc: handleSDIFFSTORE,
},
@@ -615,6 +619,7 @@ Returns the cardinality of the new set.`,
Categories: []string{constants.SetCategory, constants.WriteCategory, constants.SlowCategory},
Description: "(SINTER key [key...]) Returns the intersection of multiple sets.",
Sync: false,
Type: "BUILT_IN",
KeyExtractionFunc: sinterKeyFunc,
HandlerFunc: handleSINTER,
},
@@ -625,6 +630,7 @@ Returns the cardinality of the new set.`,
Description: `(SINTERCARD key [key...] [LIMIT limit])
Returns the cardinality of the intersection between multiple sets.`,
Sync: false,
Type: "BUILT_IN",
KeyExtractionFunc: sintercardKeyFunc,
HandlerFunc: handleSINTERCARD,
},
@@ -634,6 +640,7 @@ Returns the cardinality of the intersection between multiple sets.`,
Categories: []string{constants.SetCategory, constants.WriteCategory, constants.SlowCategory},
Description: "(SINTERSTORE destination key [key...]) Stores the intersection of multiple sets at the destination key.",
Sync: true,
Type: "BUILT_IN",
KeyExtractionFunc: sinterstoreKeyFunc,
HandlerFunc: handleSINTERSTORE,
},
@@ -643,6 +650,7 @@ Returns the cardinality of the intersection between multiple sets.`,
Categories: []string{constants.SetCategory, constants.ReadCategory, constants.FastCategory},
Description: "(SISMEMBER key member) Returns if member is contained in the set.",
Sync: false,
Type: "BUILT_IN",
KeyExtractionFunc: sismemberKeyFunc,
HandlerFunc: handleSISMEMBER,
},
@@ -652,6 +660,7 @@ Returns the cardinality of the intersection between multiple sets.`,
Categories: []string{constants.SetCategory, constants.ReadCategory, constants.SlowCategory},
Description: "(SMEMBERS key) Returns all members of a set.",
Sync: false,
Type: "BUILT_IN",
KeyExtractionFunc: smembersKeyFunc,
HandlerFunc: handleSMEMBERS,
},
@@ -661,6 +670,7 @@ Returns the cardinality of the intersection between multiple sets.`,
Categories: []string{constants.SetCategory, constants.ReadCategory, constants.FastCategory},
Description: "(SMISMEMBER key member [member...]) Returns if multiple members are in the set.",
Sync: false,
Type: "BUILT_IN",
KeyExtractionFunc: smismemberKeyFunc,
HandlerFunc: handleSMISMEMBER,
},
@@ -671,6 +681,7 @@ Returns the cardinality of the intersection between multiple sets.`,
Categories: []string{constants.SetCategory, constants.WriteCategory, constants.FastCategory},
Description: "(SMOVE source destination member) Moves a member from source set to destination set.",
Sync: true,
Type: "BUILT_IN",
KeyExtractionFunc: smoveKeyFunc,
HandlerFunc: handleSMOVE,
},
@@ -680,6 +691,7 @@ Returns the cardinality of the intersection between multiple sets.`,
Categories: []string{constants.SetCategory, constants.WriteCategory, constants.SlowCategory},
Description: "(SPOP key [count]) Returns and removes one or more random members from the set.",
Sync: true,
Type: "BUILT_IN",
KeyExtractionFunc: spopKeyFunc,
HandlerFunc: handleSPOP,
},
@@ -689,6 +701,7 @@ Returns the cardinality of the intersection between multiple sets.`,
Categories: []string{constants.SetCategory, constants.ReadCategory, constants.SlowCategory},
Description: "(SRANDMEMBER key [count]) Returns one or more random members from the set without removing them.",
Sync: false,
Type: "BUILT_IN",
KeyExtractionFunc: srandmemberKeyFunc,
HandlerFunc: handleSRANDMEMBER,
},
@@ -698,6 +711,7 @@ Returns the cardinality of the intersection between multiple sets.`,
Categories: []string{constants.SetCategory, constants.WriteCategory, constants.FastCategory},
Description: "(SREM key member [member...]) Remove one or more members from a set.",
Sync: true,
Type: "BUILT_IN",
KeyExtractionFunc: sremKeyFunc,
HandlerFunc: handleSREM,
},
@@ -707,6 +721,7 @@ Returns the cardinality of the intersection between multiple sets.`,
Categories: []string{constants.SetCategory, constants.ReadCategory, constants.SlowCategory},
Description: "(SUNION key [key...]) Returns the members of the set resulting from the union of the provided sets.",
Sync: false,
Type: "BUILT_IN",
KeyExtractionFunc: sunionKeyFunc,
HandlerFunc: handleSUNION,
},
@@ -716,6 +731,7 @@ Returns the cardinality of the intersection between multiple sets.`,
Categories: []string{constants.SetCategory, constants.WriteCategory, constants.SlowCategory},
Description: "(SUNIONSTORE destination key [key...]) Stores the union of the given sets into destination.",
Sync: true,
Type: "BUILT_IN",
KeyExtractionFunc: sunionstoreKeyFunc,
HandlerFunc: handleSUNIONSTORE,
},