richfitz / redux

:telephone_receiver::computer: Redis client for R
https://richfitz.github.io/redux
91 stars 17 forks source link

how to capture a list? #55

Closed r2evans closed 2 years ago

r2evans commented 2 years ago

What is it about a lua array that is not captured correctly by the call?

R <- redux::hiredix()

dput(R$EVAL("
  local obj = {a=9}
  return obj", 0, NULL, NULL))
# list()

R$EVAL("
  local obj = {a=9}
  return obj.a", 0, NULL, NULL)
# [1] 9
sessionInfo ```r R$version() # [1] '6.0.16' sessionInfo() # R version 4.1.2 (2021-11-01) # Platform: x86_64-w64-mingw32/x64 (64-bit) # Running under: Windows 10 x64 (build 22000) # Matrix products: default # locale: # [1] LC_COLLATE=English_United States.1252 # [2] LC_CTYPE=English_United States.1252 # [3] LC_MONETARY=English_United States.1252 # [4] LC_NUMERIC=C # [5] LC_TIME=English_United States.1252 # attached base packages: # [1] stats graphics grDevices utils datasets methods base # other attached packages: # [1] redux_1.1.3 r2_0.9.14 # loaded via a namespace (and not attached): # [1] compiler_4.1.2 R6_2.5.1 fastmap_1.1.0 cli_3.3.0 # [5] tools_4.1.2 htmltools_0.5.2 rmarkdown_2.11 knitr_1.36 # [9] xfun_0.29 digest_0.6.28 rlang_1.0.2 evaluate_0.14 ```
richfitz commented 2 years ago

I am not sure, but that seems like the same behaviour as redis-cli - are you sure you have the EVAL or lua code correct?:

$ redis-cli
127.0.0.1:6379> EVAL "local obj = {a=9}; return obj" 0 null null
(empty list or set)
127.0.0.1:6379> EVAL "local obj = {a=9}; return obj.a" 0 null null
(integer) 9
richfitz commented 2 years ago

Possibly relevant? https://stackoverflow.com/questions/24298763/redis-lua-tables-as-return-values-why-is-this-not-working

r2evans commented 2 years ago

Fair point ... my lua-fu is weak at best ...

r2evans commented 2 years ago

Thanks for the link. Apparently it's a named-list thing, not really a list thing. :-/ ...