aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/test/cache
Commit message (Collapse)AuthorAgeFilesLines
* `assert_called_with` should require `args` argumentbogdanvlviv2018-10-251-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | There are two main reasons why `assert_called_with` should require `args` argument: 1) If we want to assert that some method should be called and we don't need to check with which arguments it should be called then we should use `assert_called`. 2) `assert_called_with` without `args` argument doesn't assert anything! ```ruby assert_called_with(@object, :increment) do @object.decrement end ``` It causes false assertions in tests that could cause regressions in the project. I found this bug by working on [minitest-mock_expectations](https://github.com/bogdanvlviv/minitest-mock_expectations) gem. This gem is an extension for minitest that provides almost the same method call assertions. I was wondering whether you would consider adding "minitest-mock_expectations" to `rails/rails` instead of private `ActiveSupport::Testing::MethodCallAssertions` module. If yes, I'll send a patch - https://github.com/bogdanvlviv/rails/commit/a970ecc42c3a9637947599f2c13e3762e4b59208
* Array with single item correctly uses cache_keyGraham Turner2018-10-051-0/+49
|
* Change the empty block style to have space inside of the blockRafael Mendonça França2018-09-252-3/+3
|
* Enable `Performance/UnfreezeString` copyuuji.yaginuma2018-09-233-6/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In Ruby 2.3 or later, `String#+@` is available and `+@` is faster than `dup`. ```ruby # frozen_string_literal: true require "bundler/inline" gemfile(true) do source "https://rubygems.org" gem "benchmark-ips" end Benchmark.ips do |x| x.report('+@') { +"" } x.report('dup') { "".dup } x.compare! end ``` ``` $ ruby -v benchmark.rb ruby 2.5.1p57 (2018-03-29 revision 63029) [x86_64-linux] Warming up -------------------------------------- +@ 282.289k i/100ms dup 187.638k i/100ms Calculating ------------------------------------- +@ 6.775M (± 3.6%) i/s - 33.875M in 5.006253s dup 3.320M (± 2.2%) i/s - 16.700M in 5.032125s Comparison: +@: 6775299.3 i/s dup: 3320400.7 i/s - 2.04x slower ```
* Fix the obvious typos detected by github.com/client9/misspellKazuhiro Sera2018-08-081-1/+1
|
* Support skip nil for cache fetch (#25437)Martin2018-08-051-0/+7
| | | | | | | | | | | | * test case for fetch cache miss with skip_nil * abondon nil cache if skip_nil specified * ensure not cache key for skip nil * add document with skip_nil for Store#fetch * add a new change log entry for #25437
* Turn on performance based copsDillon Welch2018-07-231-3/+1
| | | | | | | | | | | | | | | | Use attr_reader/attr_writer instead of methods method is 12% slower Use flat_map over map.flatten(1) flatten is 66% slower Use hash[]= instead of hash.merge! with single arguments merge! is 166% slower See https://github.com/rails/rails/pull/32337 for more conversation
* Refactor #33254.Kasper Timm Hansen2018-07-011-2/+2
| | | | | | | | | | | | | Firstly, increment and decrement shouldn't care about the particulars of key expiry. They should only know that they have to pass that responsibility on to somewhere else. Secondly, it moves the key normalization back inside the instrumentation like it was originally. I think that matches the original design intention or at the very least it lets users catch haywire key truncation. Thirdly, it moves the changelog entry to the top of the file, where new entries go. I couldn't understand what the entry was saying so I tried to rewrite it.
* Fix Cache :redis_store increment/decrement ttl check and add more tests.Jason Lee2018-06-301-4/+20
|
* Add :expires_in option support for RedisCacheStore increment/decrement method.Jason Lee2018-06-291-0/+24
|
* Fix `CustomCops/AssertNot` to allow it to have failure messageRyuta Kamizono2018-05-132-13/+13
| | | | Follow up of #32605.
* Fix test: threads being nil in ensurePavel Valena2018-04-301-4/+4
| | | | when connection_pool is not installed.
* Allow rubocop check more filesbogdanvlviv2018-04-194-6/+6
| | | | | | | | | This commit fix pattern of filenames for `CustomCops/AssertNot` and `CustomCops/RefuteNot`. rubocop should check every file under `test/`. Related to #32441, #32605
* Replace `assert !` with `assert_not`Daniel Colson2018-04-193-7/+7
| | | | | This autocorrects the violations after adding a custom cop in 3305c78dcd.
* 2.6 warning: passing splat keyword arguments as a single Hashutilum2018-04-151-2/+2
| | | | | | | | | | | | Ruby 2.6.0 warns about this. ``` ruby -v ruby 2.6.0dev (2018-04-04 trunk 63085) [x86_64-linux] ``` Before, see: https://travis-ci.org/rails/rails/jobs/365740163#L1262-L1264 https://travis-ci.org/rails/rails/jobs/365944863#L2121-L2174
* Fix redis store clear keys outside the namespaceRei2018-04-151-0/+18
| | | | | | | | | | Namespace not working in RedisCacheStore#clear method. Bacause namespace = merged_options(options)[namespace] is always nil, Correct is namespace = merged_options(options)[:namespace]
* Use `SecureRandom.random_bytes` instead of `SecureRandom.bytes`yuuji.yaginuma2018-04-131-1/+1
| | | | | | | | | | `SecureRandom.byes` was added in Ruby 2.4. So, 5-2-stable build is broken because using `SecureRandom.bytes`. https://travis-ci.org/rails/rails/jobs/365740667 Also, `SecureRandom.byes` seems to an undocumented method. If need random binary strings, should use `SecureRandom.random_bytes`. https://github.com/ruby/ruby/blob/trunk/lib/securerandom.rb
* Fix `ActiveSupport::Cache` compressionGodfrey Chan2018-04-111-2/+21
| | | | (See previous commit for a description of the issue)
* Add failing test for compression bugGodfrey Chan2018-04-113-38/+123
| | | | | | | | | | | | | On Rails 5.2, when compression is enabled (which it is by default), the actual value being written to the underlying storage is actually _bigger_ than the uncompressed raw value. This is because the `@marshaled_value` instance variable (typically) gets serialized with the entry object, which is then written to the underlying storage, essentially double-storing every value (once uncompressed, once possibly compressed). This regression was introduced in #32254.
* Fix: FileStoreTest#test_filename_max_size fails in Ruby 2.5.1utilum2018-03-311-1/+3
|
* Fix Cache `read_multi` with local_cache return values.Jason Lee2018-03-211-0/+12
| | | | It should returns raw value, not instance of `ActiveSupport::Cache::Entry`.
* Redis cache store: fix constructing with a Redis instanceAdam Richardson2018-03-121-0/+6
| | | | | | | | Since `Redis#call` duck types as a Proc, we'd call `#call` on it, thinking it's a Proc. Fixed by check for the Proc explicitly instead of duck typing on `#call`. References #32233
* Remove unnecessary `respond_to?(:report_on_exception)` checkingyuuji.yaginuma2018-03-021-2/+2
| | | | Since Rails 6 requires Ruby 2.4.1+.
* Caching: MemCache and Redis stores use local cache for multi-readsGabriel Sobrinho2018-02-231-0/+10
| | | | | Fixes #31909. Closes #31911.
* Merge pull request #31866 from fatkodima/redis_cache-connection_poolRafael Mendonça França2018-02-142-2/+50
|\ | | | | | | Add support for connection pooling on RedisCacheStore
| * Add support for connection pooling on RedisCacheStorefatkodima2018-02-012-2/+50
| |
* | Use Redis#mget for RedisCacheStore#fetch_multifatkodima2018-02-051-0/+8
| |
* | Add missing instrumentation to RedisCacheStore#read_multifatkodima2018-02-056-17/+20
| |
* | RedisCacheStore: fix `#write_multi` mset serializationfatkodima2018-02-041-0/+10
|/ | | | | Closes #31886 Fixes #31884
* Revert "Merge pull request #31447 from fatkodima/redis_cache-connection_pool"George Claghorn2018-01-311-32/+0
| | | | | This reverts commit ac74e2c521f6ddc0eac02d74a1313261bcc1d60f, reversing changes made to ffdb06136152b3c5f7f4a93ca5928e16e755d228.
* Suppress expected exceptions by `report_on_exception` = `false`yuuji.yaginuma2018-01-291-0/+4
| | | | | This suppresses `Timeout::Error` exceptions. Ref: https://travis-ci.org/rails/rails/jobs/334622442#L1089-L1110
* Remove extra whitespaceDaniel Colson2018-01-251-1/+1
|
* Use assert_empty and assert_not_emptyDaniel Colson2018-01-251-1/+1
|
* Use assert_predicate and assert_not_predicateDaniel Colson2018-01-252-4/+4
|
* Improve fault tolerance for redis cache storefatkodima2018-01-234-6/+126
|
* Add support for connection pooling on RedisCacheStorefatkodima2018-01-224-50/+91
|
* Pass desired driver to Redis client constructor rather than munging global ↵George Claghorn2018-01-211-16/+12
| | | | config
* Support for connection pooling on mem cache storeGabriel Sobrinho2018-01-181-0/+74
|
* Test against the pure-Ruby Redis driverGeorge Claghorn2018-01-171-0/+6
|
* Fix constant referenceGeorge Claghorn2018-01-161-2/+1
| | | | Update the long key handling test so it triggers truncation in the Redis cache store.
* add instrumentation for read_multiIgnatius Reza2017-12-291-6/+6
| | | | currently it's not possible to know what the hit rates are from read_multi
* Test that cache stores build unversioned keysGeorge Claghorn2017-12-221-0/+12
|
* Enable `Layout/LeadingCommentSpace` to not allow cosmetic changes in the futureRyuta Kamizono2017-12-141-1/+1
| | | | Follow up of #31432.
* MemCacheStore: Support expiring countersTakumasa Ochi2017-11-201-0/+16
| | | | | | | Support `expires_in` in `ActiveSupport::Cache::MemCacheStore#increment` and `#decrement`. Closes #30716.
* Cache: Enable compression by default for values > 1kB.Jeremy Daer2017-11-132-3/+20
| | | | | | | | | | | | | Compression has long been available, but opt-in and at a 16kB threshold. It wasn't enabled by default due to CPU cost. Today it's cheap and typical cache data is eminently compressible, such as HTML or JSON fragments. Compression dramatically reduces Memcached/Redis mem usage, which means the same cache servers can store more data, which means higher hit rates. To disable compression, pass `compress: false` to the initializer.
* Built-in Redis cache storeJeremy Daer2017-11-133-3/+162
| | | | | | | | | | | * Supports vanilla Redis, hiredis, and Redis::Distributed. * Supports Memcached-like sharding across Redises with Redis::Distributed. * Fault tolerant. If the Redis server is unavailable, no exceptions are raised. Cache fetches are treated as misses and writes are dropped. * Local cache. Hot in-memory primary cache within block/middleware scope. * `read_/write_multi` support for Redis mget/mset. Use Redis::Distributed 4.0.1+ for distributed mget support. * `delete_matched` support for Redis KEYS globs.
* Fixes ActiveSupport::Cache::FileStore#cleanup bug which prevented it from ↵Erich Soares Machado2017-10-031-0/+1
| | | | cleaning up the expired cache keys
* Use File::NULL instead of "/dev/null"Kazuhiro NISHIYAMA2017-07-311-1/+1
|
* [Active Support] `rubocop -a --only Layout/EmptyLineAfterMagicComment`Koichi ITO2017-07-1119-0/+19
|
* Use frozen-string-literal in ActiveSupportKir Shatrov2017-07-0919-0/+19
|