aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/cache
Commit message (Collapse)AuthorAgeFilesLines
* Merge pull request #36656 from Edouard-chin/ec-local-cache-referenceRafael França2019-07-151-1/+4
|\ | | | | Return a copy of the cache entry when local_cache exists:
| * Return a copy of the cache entry when local_cache exists:Edouard CHIN2019-07-111-1/+4
| | | | | | | | | | | | | | | | | | | | | | | | - When the local cache exists (during the request lifecycle), the entry returned from the LocalStore is passed as a reference which means mutable object can accidentaly get modified. This behaviour seems unnecessarily unsafe and is prone to issues like it happened in our application. This patch dup the `Entry` returned from the cache and dup it's internal value.
* | active_support/core_ext/object/duplicable is not in use hereRyuta Kamizono2019-07-161-1/+0
|/
* Enable `Layout/EmptyLinesAroundAccessModifier` copRyuta Kamizono2019-06-132-2/+0
| | | | | | | | | | | We sometimes say "✂️ newline after `private`" in a code review (e.g. https://github.com/rails/rails/pull/18546#discussion_r23188776, https://github.com/rails/rails/pull/34832#discussion_r244847195). Now `Layout/EmptyLinesAroundAccessModifier` cop have new enforced style `EnforcedStyle: only_before` (https://github.com/rubocop-hq/rubocop/pull/7059). That cop and enforced style will reduce the our code review cost.
* Document redis: Object optionSteven Harman2019-04-181-5/+7
| | | | | | | There are four ways to pass the redis option, but only three were documented. This is now consistent with implementation. [ci skip]
* Redis fetch without names returns {}David Verhasselt2019-04-121-0/+1
| | | | | | | When trying to call mget in Redis without any parameters, a Redis error is thrown. To avoid this, we circumvent Redis entirely when there are no key names given.
* Use Dir#children and Dir#each_child instead of excluding "." and ".."Ricardo Díaz2019-02-131-10/+3
| | | | | | | | Both methods were introduced in Ruby 2.5 and fit this use case very nicely: listing a directory's entries excluding the "." and ".." nodes. The private method #exclude_from was removed as it no longer serves its original purpose.
* Fix elapsed time calculationsbogdanvlviv2019-02-081-2/+2
| | | | | | | | | | | | | | | | | | | I've found a few places in Rails code base where I think it makes sense to calculate elapsed time more precisely by using `Concurrent.monotonic_time`: - Fix calculation of elapsed time in `ActiveSupport::Cache::MemoryStore#prune` - Fix calculation of elapsed time in `ActiveRecord::ConnectionAdapters::ConnectionPool::Queue#wait_poll` - Fix calculation of elapsed time in `ActiveRecord::ConnectionAdapters::ConnectionPool#attempt_to_checkout_all_existing_connections` - Fix calculation of elapsed time in `ActiveRecord::ConnectionAdapters::Mysql2Adapter#explain` See https://docs.ruby-lang.org/en/2.5.0/Process.html#method-c-clock_gettime https://blog.dnsimple.com/2018/03/elapsed-time-with-ruby-the-right-way Related to 7c4542146f0dde962205e5a90839349631ae60fb
* Enable `Style/RedundantBegin` cop to avoid newly adding redundant begin blockRyuta Kamizono2018-12-211-6/+4
| | | | | | | | | | Currently we sometimes find a redundant begin block in code review (e.g. https://github.com/rails/rails/pull/33604#discussion_r209784205). I'd like to enable `Style/RedundantBegin` cop to avoid that, since rescue/else/ensure are allowed inside do/end blocks in Ruby 2.5 (https://bugs.ruby-lang.org/issues/12906), so we'd probably meets with that situation than before.
* Switch to supports_cache_versioning? check to a class methodschneems2018-09-205-20/+10
| | | | | - Moving the `supports_cache_versioning?` check to a class method. - Shorten the method doc. - Expand on the error message.
* [close #33907] Error when using "recyclable" cache keys with a store that ↵schneems2018-09-205-0/+35
| | | | | | | | | | | | | | does not support it If you are using the "in cache versioning" also known as "recyclable cache keys" the cache store must be aware of this scheme, otherwise you will generate cache entries that never invalidate. This PR adds a check to the initialization process to ensure that if recyclable cache keys are being used via ``` config.active_record.cache_versioning = true ``` Then the cache store needs to show that it supports this versioning scheme. Cache stores can let Rails know that they support this scheme by adding a method `supports_in_cache_versioning?` and returning true.
* Faster File Storeschneems2018-09-061-6/+10
| | | | | | Memory before 1826584.8 memory after: 1797795.6 difference: 1.58% memory (speed) savings. When the key is not longer than the limit we can avoid allocating two strings and an array.
* Refactor #33254.Kasper Timm Hansen2018-07-011-16/+16
| | | | | | | | | | | | | 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-2/+2
|
* Add :expires_in option support for RedisCacheStore increment/decrement method.Jason Lee2018-06-291-2/+22
|
* Redis cache store: avoid blocking the server in `#delete_matched`Gleb Mazovetskiy2018-04-181-6/+13
| | | | | | | | | | | | | | | | | | | | Fixes #32610. Closes #32614. Lua scripts in redis are *blocking*, meaning that no other client can execute any commands while the script is running. See https://redis.io/commands/eval#atomicity-of-scripts. This results in the following exceptions once the number of keys is sufficiently large: BUSY Redis is busy running a script. You can only call SCRIPT KILL or SHUTDOWN NOSAVE. This commit replaces the lua-based implementation with one that uses `SCAN` and `DEL` in batches. This doesn't block the server. The primary limitation of `SCAN`, i.e. potential duplicate keys, is of no consequence here, because `DEL` ignores keys that do not exist.
* Fix redis store clear keys outside the namespaceRei2018-04-151-1/+1
| | | | | | | | | | Namespace not working in RedisCacheStore#clear method. Bacause namespace = merged_options(options)[namespace] is always nil, Correct is namespace = merged_options(options)[:namespace]
* Fix Cache `read_multi` with local_cache return values.Jason Lee2018-03-211-1/+8
| | | | It should returns raw value, not instance of `ActiveSupport::Cache::Entry`.
* Fix unclosed tags in `RedisCacheStore` docs [ci skip]yuuji.yaginuma2018-03-191-1/+1
|
* Redis cache store: fix constructing with a Redis instanceAdam Richardson2018-03-121-1/+1
| | | | | | | | 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
* Caching: MemCache and Redis stores use local cache for multi-readsGabriel Sobrinho2018-02-231-0/+17
| | | | | Fixes #31909. Closes #31911.
* Rails 6 requires Ruby 2.4.1+Jeremy Daer2018-02-171-1/+0
| | | | | | Skipping over 2.4.0 to sidestep the `"symbol_from_string".to_sym.dup` bug. References #32028
* Merge pull request #31866 from fatkodima/redis_cache-connection_poolRafael Mendonça França2018-02-142-22/+31
|\ | | | | | | Add support for connection pooling on RedisCacheStore
| * Add support for connection pooling on RedisCacheStorefatkodima2018-02-012-22/+31
| |
* | Doc: fixes typo `cache:` -> `compress:`Joseph Page2018-02-121-1/+1
| | | | | | | | | | | | [ci skip] Closes #31967
* | Use Redis#mget for RedisCacheStore#fetch_multifatkodima2018-02-051-0/+8
| |
* | Add missing instrumentation to RedisCacheStore#read_multifatkodima2018-02-051-1/+5
| |
* | Redis cache store: consolidate serializationJeremy Daer2018-02-041-17/+21
| | | | | | | | Use `serialize_entry` throughout and introduce `serialize_entries`.
* | RedisCacheStore: fix `#write_multi` mset serializationfatkodima2018-02-041-1/+8
|/ | | | | Closes #31886 Fixes #31884
* Revert "Merge pull request #31447 from fatkodima/redis_cache-connection_pool"George Claghorn2018-01-312-54/+23
| | | | | This reverts commit ac74e2c521f6ddc0eac02d74a1313261bcc1d60f, reversing changes made to ffdb06136152b3c5f7f4a93ca5928e16e755d228.
* Improve fault tolerance for redis cache storefatkodima2018-01-231-4/+11
|
* Add support for connection pooling on RedisCacheStorefatkodima2018-01-222-23/+54
|
* Support for connection pooling on mem cache storeGabriel Sobrinho2018-01-181-9/+25
|
* Convert keys to binary in the Redis cache storeGeorge Claghorn2018-01-171-1/+1
| | | | Fix encoding errors when using the pure-Ruby Redis driver instead of Hiredis. Dodge incompatibilities between UTF-8 and arbitrary value encodings, which rear their heads when the Redis driver tries to build a single command string from incompatibly-encoded keys and values.
* Fix constant referenceGeorge Claghorn2018-01-161-1/+1
| | | | Update the long key handling test so it triggers truncation in the Redis cache store.
* add instrumentation for read_multiIgnatius Reza2017-12-291-22/+18
| | | | currently it's not possible to know what the hit rates are from read_multi
* RedisCacheStore - Fix Default Error HandlerJesse Doyle2017-12-141-3/+5
| | | | | | | | | * The `DEFAULT_ERROR_HANDLER` constant in `ActiveSupport::Cache::RedisCacheStore` contained references to an undefined argument `e`, which is supposed to refer to the `exception` parameter. * Update the default error handler proc to correctly reference the `exception` parameter.
* Introduced `ActiveSupport::Digest` that allows to specify hash function ↵Dmitri Dolguikh2017-12-122-3/+2
| | | | | | | | implementation and defaults to `Digest::MD5`. Replaced calls to `::Digest::MD5.hexdigest` with calls to `ActiveSupport::Digest.hexdigest`.
* Update incorrect backtick usage in RDoc to teletypeT.J. Schuck2017-11-221-5/+5
| | | [ci skip]
* MemCacheStore: Support expiring countersTakumasa Ochi2017-11-201-2/+2
| | | | | | | Support `expires_in` in `ActiveSupport::Cache::MemCacheStore#increment` and `#decrement`. Closes #30716.
* Generate `keys` instead of `keys_to_names`Ryuta Kamizono2017-11-201-3/+3
| | | | `keys_to_names` is used only for `keys_to_names.keys`.
* Fix "warning: assigned but unused variable - key"yuuji.yaginuma2017-11-181-1/+1
| | | | Ref: https://travis-ci.org/rails/rails/jobs/303840778#L1974
* Built-in Redis cache storeJeremy Daer2017-11-131-0/+404
| | | | | | | | | | | * 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.
* [Active Support] require_relative => requireAkira Matsuda2017-10-213-8/+8
| | | | This basically reverts 8da30ad6be34339124ba4cb4e36aea260dda12bc
* Fixes ActiveSupport::Cache::FileStore#cleanup bug which prevented it from ↵Erich Soares Machado2017-10-031-3/+2
| | | | cleaning up the expired cache keys
* Update links to use https instead of http [ci skip]Yoshiyuki Hirano2017-08-221-1/+1
|
* [Active Support] `rubocop -a --only Layout/EmptyLineAfterMagicComment`Koichi ITO2017-07-116-0/+6
|
* Use frozen-string-literal in ActiveSupportKir Shatrov2017-07-096-0/+6
|
* [Active Support] require => require_relativeAkira Matsuda2017-07-013-8/+8
|
* Cache: test coverage for cleanup behavior with local cache strategyEugene Kenny2017-06-101-1/+1
| | | | | | No need to pass `#cleanup` options through to `LocalCache#clear`. Fixes #29081. References #25628.