Skip to content
Open
Show file tree
Hide file tree
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
24 changes: 12 additions & 12 deletions src/lua-scripts/hash.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,63 +26,63 @@ export const SCRIPTS: {
fixedWindow: {
limit: {
script: Single.fixedWindowLimitScript,
hash: "472e55443b62f60d0991028456c57815a387066d"
hash: "4ef8749b9e927b157546ebad13061fa86b9ffc2e"
},
getRemaining: {
script: Single.fixedWindowRemainingTokensScript,
hash: "40515c9dd0a08f8584f5f9b593935f6a87c1c1c3"
hash: "e62252cb05b4676b27a5d396da02f0ca0d375d88"
},
},
slidingWindow: {
limit: {
script: Single.slidingWindowLimitScript,
hash: "977fb636fb5ceb7e98a96d1b3a1272ba018efdae"
hash: "5cd9665be7533e4dfabb3581021737fc69b41ae8"
},
getRemaining: {
script: Single.slidingWindowRemainingTokensScript,
hash: "ee3a3265fad822f83acad23f8a1e2f5c0b156b03"
hash: "1bdbbdb2082bb557084518c64486d7d5a29d1bfe"
},
},
tokenBucket: {
limit: {
script: Single.tokenBucketLimitScript,
hash: "b35c5bc0b7fdae7dd0573d4529911cabaf9d1d89"
hash: "8f7286b9b0f65d631f760ba615f7b3c598a569a3"
},
getRemaining: {
script: Single.tokenBucketRemainingTokensScript,
hash: "deb03663e8af5a968deee895dd081be553d2611b"
hash: "08d3b3381c507b6f7bfec1bbfa0a6053434b16bd"
},
},
cachedFixedWindow: {
limit: {
script: Single.cachedFixedWindowLimitScript,
hash: "c26b12703dd137939b9a69a3a9b18e906a2d940f"
hash: "1861a700bafe96c833a483af6b1c28a8897cfdb0"
},
getRemaining: {
script: Single.cachedFixedWindowRemainingTokenScript,
hash: "8e8f222ccae68b595ee6e3f3bf2199629a62b91a"
hash: "eb82f0e853d2fc9a236fa9bfbe704fda6ac2fc36"
},
}
},
multiRegion: {
fixedWindow: {
limit: {
script: Multi.fixedWindowLimitScript,
hash: "a8c14f3835aa87bd70e5e2116081b81664abcf5c"
hash: "e04b753a75909b7f99aae4c04cf8869a8de02a9e"
},
getRemaining: {
script: Multi.fixedWindowRemainingTokensScript,
hash: "8ab8322d0ed5fe5ac8eb08f0c2e4557f1b4816fd"
hash: "e066c8ce3eaca142b0894ad1541e0a58c9924819"
},
},
slidingWindow: {
limit: {
script: Multi.slidingWindowLimitScript,
hash: "1e7ca8dcd2d600a6d0124a67a57ea225ed62921b"
hash: "aeb4d8f381e8dafc8e69041baae1324d254ded44"
},
getRemaining: {
script: Multi.slidingWindowRemainingTokensScript,
hash: "558c9306b7ec54abb50747fe0b17e5d44bd24868"
hash: "87828c1088f6a8d1f512a434ea330189982a1c0a"
},
},
}
Expand Down
8 changes: 4 additions & 4 deletions src/lua-scripts/multi.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export const fixedWindowLimitScript = `
export const fixedWindowLimitScript = `#!lua flags=allow-key-locking
local key = KEYS[1]
local id = ARGV[1]
local window = ARGV[2]
Expand All @@ -14,7 +14,7 @@ export const fixedWindowLimitScript = `

return fields
`;
export const fixedWindowRemainingTokensScript = `
export const fixedWindowRemainingTokensScript = `#!lua flags=allow-key-locking
local key = KEYS[1]
local tokens = 0

Expand All @@ -23,7 +23,7 @@ export const fixedWindowRemainingTokensScript = `
return fields
`;

export const slidingWindowLimitScript = `
export const slidingWindowLimitScript = `#!lua flags=allow-key-locking
local currentKey = KEYS[1] -- identifier including prefixes
local previousKey = KEYS[2] -- key of the previous bucket
local tokens = tonumber(ARGV[1]) -- tokens per window
Expand Down Expand Up @@ -61,7 +61,7 @@ export const slidingWindowLimitScript = `
return {currentFields, previousFields, true}
`;

export const slidingWindowRemainingTokensScript = `
export const slidingWindowRemainingTokensScript = `#!lua flags=allow-key-locking
local currentKey = KEYS[1] -- identifier including prefixes
local previousKey = KEYS[2] -- key of the previous bucket
local now = ARGV[1] -- current timestamp in milliseconds
Expand Down
16 changes: 8 additions & 8 deletions src/lua-scripts/single.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export const fixedWindowLimitScript = `
export const fixedWindowLimitScript = `#!lua flags=allow-key-locking
local key = KEYS[1]
local dynamicLimitKey = KEYS[2] -- optional: key for dynamic limit in redis
local tokens = tonumber(ARGV[1]) -- default limit
Expand All @@ -24,7 +24,7 @@ export const fixedWindowLimitScript = `
return {r, effectiveLimit}
`;

export const fixedWindowRemainingTokensScript = `
export const fixedWindowRemainingTokensScript = `#!lua flags=allow-key-locking
local key = KEYS[1]
local dynamicLimitKey = KEYS[2] -- optional: key for dynamic limit in redis
local tokens = tonumber(ARGV[1]) -- default limit
Expand All @@ -47,7 +47,7 @@ export const fixedWindowRemainingTokensScript = `
return {effectiveLimit - usedTokens, effectiveLimit}
`;

export const slidingWindowLimitScript = `
export const slidingWindowLimitScript = `#!lua flags=allow-key-locking
local currentKey = KEYS[1] -- identifier including prefixes
local previousKey = KEYS[2] -- key of the previous bucket
local dynamicLimitKey = KEYS[3] -- optional: key for dynamic limit in redis
Expand Down Expand Up @@ -92,7 +92,7 @@ export const slidingWindowLimitScript = `
return {effectiveLimit - ( newValue + requestsInPreviousWindow ), effectiveLimit}
`;

export const slidingWindowRemainingTokensScript = `
export const slidingWindowRemainingTokensScript = `#!lua flags=allow-key-locking
local currentKey = KEYS[1] -- identifier including prefixes
local previousKey = KEYS[2] -- key of the previous bucket
local dynamicLimitKey = KEYS[3] -- optional: key for dynamic limit in redis
Expand Down Expand Up @@ -127,7 +127,7 @@ export const slidingWindowRemainingTokensScript = `
return {effectiveLimit - usedTokens, effectiveLimit}
`;

export const tokenBucketLimitScript = `
export const tokenBucketLimitScript = `#!lua flags=allow-key-locking
local key = KEYS[1] -- identifier including prefixes
local dynamicLimitKey = KEYS[2] -- optional: key for dynamic limit in redis
local maxTokens = tonumber(ARGV[1]) -- default maximum number of tokens
Expand Down Expand Up @@ -183,7 +183,7 @@ export const tokenBucketLimitScript = `

export const tokenBucketIdentifierNotFound = -1

export const tokenBucketRemainingTokensScript = `
export const tokenBucketRemainingTokensScript = `#!lua flags=allow-key-locking
local key = KEYS[1]
local dynamicLimitKey = KEYS[2] -- optional: key for dynamic limit in redis
local maxTokens = tonumber(ARGV[1]) -- default maximum number of tokens
Expand All @@ -206,7 +206,7 @@ export const tokenBucketRemainingTokensScript = `
return {tonumber(bucket[2]), tonumber(bucket[1]), effectiveLimit}
`;

export const cachedFixedWindowLimitScript = `
export const cachedFixedWindowLimitScript = `#!lua flags=allow-key-locking
local key = KEYS[1]
local window = ARGV[1]
local incrementBy = ARGV[2] -- increment rate per request at a given value, default is 1
Expand All @@ -221,7 +221,7 @@ export const cachedFixedWindowLimitScript = `
return r
`;

export const cachedFixedWindowRemainingTokenScript = `
export const cachedFixedWindowRemainingTokenScript = `#!lua flags=allow-key-locking
local key = KEYS[1]
local tokens = 0

Expand Down
Loading