Sha256: 9d788d4b71937d166ded36d0641e4bc727e5eac264a4886adec460da70d1bf80
Contents?: true
Size: 1.67 KB
Versions: 2
Compression:
Stored size: 1.67 KB
Contents
require "test_helper" class MemoizedCacheProxyTest < IdentityCache::TestCase def setup super IdentityCache.cache_backend = Rails.cache end def test_chaging_default_cache IdentityCache.cache_backend = ActiveSupport::Cache::MemoryStore.new IdentityCache.cache.write('foo', 'bar') assert_equal 'bar', IdentityCache.cache.read('foo') end def test_read_should_short_circuit_on_memoized_values Rails.cache.expects(:read).never IdentityCache.cache.with_memoization do IdentityCache.cache.write('foo', 'bar') assert_equal 'bar', IdentityCache.cache.read('foo') end end def test_read_should_try_memcached_on_not_memoized_values Rails.cache.expects(:read).with('foo').returns('bar') IdentityCache.cache.with_memoization do assert_equal 'bar', IdentityCache.cache.read('foo') end end def test_write_should_memoize_values Rails.cache.expects(:read).never Rails.cache.expects(:write).with('foo', 'bar') IdentityCache.cache.with_memoization do IdentityCache.cache.write('foo', 'bar') assert_equal 'bar', IdentityCache.cache.read('foo') end end def test_read_multi_with_partially_memoized_should_read_missing_keys_from_memcache IdentityCache.cache.write('foo', 'bar') Rails.cache.write('fooz', 'baz') IdentityCache.cache.with_memoization do assert_equal({'foo' => 'bar', 'fooz' => 'baz'}, IdentityCache.cache.read_multi('foo', 'fooz')) end end def test_with_memoization_should_not_clear_rails_cache_when_the_block_ends IdentityCache.cache.with_memoization do IdentityCache.cache.write('foo', 'bar') end assert_equal 'bar', Rails.cache.read('foo') end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
identity_cache-0.0.2 | test/memoized_cache_proxy_test.rb |
identity_cache-0.0.1 | test/memoized_cache_proxy_test.rb |