aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/test
diff options
context:
space:
mode:
authorTakumasa Ochi <aeroastro@users.noreply.github.com>2017-11-19 03:50:59 +0900
committerJeremy Daer <jeremydaer@gmail.com>2017-11-20 14:49:11 -0800
commitb22ee64b5b30c6d5039c292235e10b24b1057f6d (patch)
treebead1307088117c6c95269f261fdb75242f8ca54 /activesupport/test
parentae7593e7e842ec5efb8d58a7ce005ba55fd4c886 (diff)
downloadrails-b22ee64b5b30c6d5039c292235e10b24b1057f6d.tar.gz
rails-b22ee64b5b30c6d5039c292235e10b24b1057f6d.tar.bz2
rails-b22ee64b5b30c6d5039c292235e10b24b1057f6d.zip
MemCacheStore: Support expiring counters
Support `expires_in` in `ActiveSupport::Cache::MemCacheStore#increment` and `#decrement`. Closes #30716.
Diffstat (limited to 'activesupport/test')
-rw-r--r--activesupport/test/cache/stores/mem_cache_store_test.rb16
1 files changed, 16 insertions, 0 deletions
diff --git a/activesupport/test/cache/stores/mem_cache_store_test.rb b/activesupport/test/cache/stores/mem_cache_store_test.rb
index 1b73fb65eb..99624caf8a 100644
--- a/activesupport/test/cache/stores/mem_cache_store_test.rb
+++ b/activesupport/test/cache/stores/mem_cache_store_test.rb
@@ -57,6 +57,22 @@ class MemCacheStoreTest < ActiveSupport::TestCase
end
end
+ def test_increment_expires_in
+ cache = ActiveSupport::Cache.lookup_store(:mem_cache_store, raw: true)
+ cache.clear
+ assert_called_with cache.instance_variable_get(:@data), :incr, [ "foo", 1, 60 ] do
+ cache.increment("foo", 1, expires_in: 60)
+ end
+ end
+
+ def test_decrement_expires_in
+ cache = ActiveSupport::Cache.lookup_store(:mem_cache_store, raw: true)
+ cache.clear
+ assert_called_with cache.instance_variable_get(:@data), :decr, [ "foo", 1, 60 ] do
+ cache.decrement("foo", 1, expires_in: 60)
+ end
+ end
+
def test_local_cache_raw_values_with_marshal
cache = ActiveSupport::Cache.lookup_store(:mem_cache_store, raw: true)
cache.clear