Files
lukaszraczylo e64fc7f730 Add redis support for distributed caching (#83)
* Add redis support for distributed caching

* Move towards the self-provided Redis connection pool and RESP protocol implementation.
Official redis client library won't work with yaegi.

* fixup! Move towards the self-provided Redis connection pool and RESP protocol implementation. Official redis client library won't work with yaegi.

* fixup! fixup! Move towards the self-provided Redis connection pool and RESP protocol implementation. Official redis client library won't work with yaegi.

* fixup! fixup! fixup! Move towards the self-provided Redis connection pool and RESP protocol implementation. Official redis client library won't work with yaegi.

* fixup! fixup! fixup! fixup! Move towards the self-provided Redis connection pool and RESP protocol implementation. Official redis client library won't work with yaegi.

* fixup! fixup! fixup! fixup! fixup! Move towards the self-provided Redis connection pool and RESP protocol implementation. Official redis client library won't work with yaegi.

* ... and another all nighter.

* fixup! ... and another all nighter.

* fixup! fixup! ... and another all nighter.

* fixup! fixup! fixup! ... and another all nighter.

* Resolve issue #85 by adding ability to set custom claims in JWT tokens

* Remove redundant validation in auth middleware ( issue #89 )

* Add ability to set cookie prefix for session cookies ( #87 )

* fixup! Add ability to set cookie prefix for session cookies ( #87 )

* Add ability to set cookie max age - issue #91

* Potential fix for code scanning alert no. 10: Size computation for allocation may overflow

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>

* fixup! Merge main into 0.8.0-redis: resolve conflicts

---------

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
2025-11-30 02:18:46 +00:00

101 lines
1.8 KiB
Go

package lua
import (
"sort"
)
func OpenTable(L *LState) int {
tabmod := L.RegisterModule(TabLibName, tableFuncs)
L.Push(tabmod)
return 1
}
var tableFuncs = map[string]LGFunction{
"getn": tableGetN,
"concat": tableConcat,
"insert": tableInsert,
"maxn": tableMaxN,
"remove": tableRemove,
"sort": tableSort,
}
func tableSort(L *LState) int {
tbl := L.CheckTable(1)
sorter := lValueArraySorter{L, nil, tbl.array}
if L.GetTop() != 1 {
sorter.Fn = L.CheckFunction(2)
}
sort.Sort(sorter)
return 0
}
func tableGetN(L *LState) int {
L.Push(LNumber(L.CheckTable(1).Len()))
return 1
}
func tableMaxN(L *LState) int {
L.Push(LNumber(L.CheckTable(1).MaxN()))
return 1
}
func tableRemove(L *LState) int {
tbl := L.CheckTable(1)
if L.GetTop() == 1 {
L.Push(tbl.Remove(-1))
} else {
L.Push(tbl.Remove(L.CheckInt(2)))
}
return 1
}
func tableConcat(L *LState) int {
tbl := L.CheckTable(1)
sep := LString(L.OptString(2, ""))
i := L.OptInt(3, 1)
j := L.OptInt(4, tbl.Len())
if L.GetTop() == 3 {
if i > tbl.Len() || i < 1 {
L.Push(emptyLString)
return 1
}
}
i = intMax(intMin(i, tbl.Len()), 1)
j = intMin(intMin(j, tbl.Len()), tbl.Len())
if i > j {
L.Push(emptyLString)
return 1
}
//TODO should flushing?
retbottom := L.GetTop()
for ; i <= j; i++ {
v := tbl.RawGetInt(i)
if !LVCanConvToString(v) {
L.RaiseError("invalid value (%s) at index %d in table for concat", v.Type().String(), i)
}
L.Push(v)
if i != j {
L.Push(sep)
}
}
L.Push(stringConcat(L, L.GetTop()-retbottom, L.reg.Top()-1))
return 1
}
func tableInsert(L *LState) int {
tbl := L.CheckTable(1)
nargs := L.GetTop()
if nargs == 1 {
L.RaiseError("wrong number of arguments")
}
if L.GetTop() == 2 {
tbl.Append(L.Get(2))
return 0
}
tbl.Insert(int(L.CheckInt(2)), L.CheckAny(3))
return 0
}
//