class CacheStoreNamespaceTest

Public Instance Methods

test_delete_matched_key() click to toggle source
# File activesupport/test/cache/cache_store_namespace_test.rb, line 32
def test_delete_matched_key
  cache = ActiveSupport::Cache.lookup_store(:memory_store, namespace: "foo")
  cache.write("foo", "bar")
  cache.write("fu", "baz")
  cache.delete_matched(/OO/i)
  assert !cache.exist?("foo")
  assert cache.exist?("fu")
end
test_delete_matched_key_start() click to toggle source
# File activesupport/test/cache/cache_store_namespace_test.rb, line 23
def test_delete_matched_key_start
  cache = ActiveSupport::Cache.lookup_store(:memory_store, namespace: "tester")
  cache.write("foo", "bar")
  cache.write("fu", "baz")
  cache.delete_matched(/^fo/)
  assert !cache.exist?("foo")
  assert cache.exist?("fu")
end
test_proc_namespace() click to toggle source
# File activesupport/test/cache/cache_store_namespace_test.rb, line 14
def test_proc_namespace
  test_val = "tester"
  proc = lambda { test_val }
  cache = ActiveSupport::Cache.lookup_store(:memory_store, namespace: proc)
  cache.write("foo", "bar")
  assert_equal "bar", cache.read("foo")
  assert_equal "bar", cache.instance_variable_get(:@data)["tester:foo"].value
end
test_static_namespace() click to toggle source
# File activesupport/test/cache/cache_store_namespace_test.rb, line 7
def test_static_namespace
  cache = ActiveSupport::Cache.lookup_store(:memory_store, namespace: "tester")
  cache.write("foo", "bar")
  assert_equal "bar", cache.read("foo")
  assert_equal "bar", cache.instance_variable_get(:@data)["tester:foo"].value
end