scan.tcl 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. set testmodule [file normalize tests/modules/scan.so]
  2. start_server {tags {"modules"}} {
  3. r module load $testmodule
  4. test {Module scan keyspace} {
  5. # the module create a scan command with filtering which also return values
  6. r set x 1
  7. r set y 2
  8. r set z 3
  9. r hset h f v
  10. lsort [r scan.scan_strings]
  11. } {{x 1} {y 2} {z 3}}
  12. test {Module scan hash ziplist} {
  13. r hmset hh f1 v1 f2 v2
  14. lsort [r scan.scan_key hh]
  15. } {{f1 v1} {f2 v2}}
  16. test {Module scan hash dict} {
  17. r config set hash-max-ziplist-entries 2
  18. r hmset hh f3 v3
  19. lsort [r scan.scan_key hh]
  20. } {{f1 v1} {f2 v2} {f3 v3}}
  21. test {Module scan zset ziplist} {
  22. r zadd zz 1 f1 2 f2
  23. lsort [r scan.scan_key zz]
  24. } {{f1 1} {f2 2}}
  25. test {Module scan zset dict} {
  26. r config set zset-max-ziplist-entries 2
  27. r zadd zz 3 f3
  28. lsort [r scan.scan_key zz]
  29. } {{f1 1} {f2 2} {f3 3}}
  30. test {Module scan set intset} {
  31. r sadd ss 1 2
  32. lsort [r scan.scan_key ss]
  33. } {{1 {}} {2 {}}}
  34. test {Module scan set dict} {
  35. r config set set-max-intset-entries 2
  36. r sadd ss 3
  37. lsort [r scan.scan_key ss]
  38. } {{1 {}} {2 {}} {3 {}}}
  39. }