2
0

cas.tcl 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. start_server {tags {"cas"}} {
  2. test {EXEC works on WATCHed key not modified} {
  3. r watch x y z
  4. r watch k
  5. r multi
  6. r ping
  7. r exec
  8. } {PONG}
  9. test {EXEC fail on WATCHed key modified (1 key of 1 watched)} {
  10. r set x 30
  11. r watch x
  12. r set x 40
  13. r multi
  14. r ping
  15. r exec
  16. } {}
  17. test {EXEC fail on WATCHed key modified (1 key of 5 watched)} {
  18. r set x 30
  19. r watch a b x k z
  20. r set x 40
  21. r multi
  22. r ping
  23. r exec
  24. } {}
  25. test {After successful EXEC key is no longer watched} {
  26. r set x 30
  27. r watch x
  28. r multi
  29. r ping
  30. r exec
  31. r set x 40
  32. r multi
  33. r ping
  34. r exec
  35. } {PONG}
  36. test {After failed EXEC key is no longer watched} {
  37. r set x 30
  38. r watch x
  39. r set x 40
  40. r multi
  41. r ping
  42. r exec
  43. r set x 40
  44. r multi
  45. r ping
  46. r exec
  47. } {PONG}
  48. test {It is possible to UNWATCH} {
  49. r set x 30
  50. r watch x
  51. r set x 40
  52. r unwatch
  53. r multi
  54. r ping
  55. r exec
  56. } {PONG}
  57. test {UNWATCH when there is nothing watched works as expected} {
  58. r unwatch
  59. } {OK}
  60. test {FLUSHALL is able to touch the watched keys} {
  61. r set x 30
  62. r watch x
  63. r flushall
  64. r multi
  65. r ping
  66. r exec
  67. } {}
  68. test {FLUSHALL does not touch non affected keys} {
  69. r del x
  70. r watch x
  71. r flushall
  72. r multi
  73. r ping
  74. r exec
  75. } {PONG}
  76. test {FLUSHDB is able to touch the watched keys} {
  77. r set x 30
  78. r watch x
  79. r flushdb
  80. r multi
  81. r ping
  82. r exec
  83. } {}
  84. test {FLUSHDB does not touch non affected keys} {
  85. r del x
  86. r watch x
  87. r flushdb
  88. r multi
  89. r ping
  90. r exec
  91. } {PONG}
  92. test {WATCH is able to remember the DB a key belongs to} {
  93. r select 5
  94. r set x 30
  95. r watch x
  96. r select 1
  97. r set x 10
  98. r select 5
  99. r multi
  100. r ping
  101. r exec
  102. } {PONG}
  103. test {WATCH will consider touched keys target of EXPIRE} {
  104. r del x
  105. r set x foo
  106. r watch x
  107. r expire x 10
  108. r multi
  109. r ping
  110. r exec
  111. } {}
  112. test {WATCH will not consider touched expired keys} {
  113. r del x
  114. r set x foo
  115. r expire x 2
  116. r watch x
  117. after 3000
  118. r multi
  119. r ping
  120. r exec
  121. } {PONG}
  122. }