1
0

scan.tcl 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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 with int value} {
  17. r hmset hh1 f1 1
  18. lsort [r scan.scan_key hh1]
  19. } {{f1 1}}
  20. test {Module scan hash dict} {
  21. r config set hash-max-ziplist-entries 2
  22. r hmset hh f3 v3
  23. lsort [r scan.scan_key hh]
  24. } {{f1 v1} {f2 v2} {f3 v3}}
  25. test {Module scan zset ziplist} {
  26. r zadd zz 1 f1 2 f2
  27. lsort [r scan.scan_key zz]
  28. } {{f1 1} {f2 2}}
  29. test {Module scan zset dict} {
  30. r config set zset-max-ziplist-entries 2
  31. r zadd zz 3 f3
  32. lsort [r scan.scan_key zz]
  33. } {{f1 1} {f2 2} {f3 3}}
  34. test {Module scan set intset} {
  35. r sadd ss 1 2
  36. lsort [r scan.scan_key ss]
  37. } {{1 {}} {2 {}}}
  38. test {Module scan set dict} {
  39. r config set set-max-intset-entries 2
  40. r sadd ss 3
  41. lsort [r scan.scan_key ss]
  42. } {{1 {}} {2 {}} {3 {}}}
  43. }