aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/cache
Commit message (Collapse)AuthorAgeFilesLines
* 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.
* Revert #25628. Incomplete change + needs a deprecation cycle.Jeremy Daer2017-06-102-4/+4
| | | | | | | | | See https://github.com/rails/rails/issues/29067#issuecomment-301342084 for rationale. This reverts commit b76f82d714e590c20370e72fa36fa574c4f17650. Fixes #29067. Fixes #29081.
* Use recyclable cache keys (#29092)David Heinemeier Hansson2017-05-181-1/+7
|
* Don't cache locally if unless_exist was passedEugene Kenny2017-05-141-1/+6
| | | | | | | | | | Some cache backends support the `unless_exist` option, which tells them not to overwrite an existing entry. The local cache currently always stores the new value, even though the backend may have rejected it. Since we can't tell which value will end up in the backend cache, we should delete the key from the local cache, so that the next read for that key will go to the backend and pick up the correct value.
* Restore 5.minutes changed in #28204Andrew White2017-03-151-1/+1
|
* AS:Cache:MemoryStore doc fixes [ci skip] (#28389)Vipul A M2017-03-121-1/+1
|
* Merge pull request #27051 from devonestes/adding-cache-clear-docsVipul A M2017-03-121-0/+2
|\ | | | | Add missing documentation for MemoryStore#clear [ci skip]
| * Add missing documentation for MemoryStore#clear [ci skip]Devon Estes2016-11-151-0/+2
| | | | | | | | | | We were missing some form of documentation for this method, so I've gone ahead and added some!
* | Make sure local cache cleared even it's throwing:Lin Jen-Shin2017-03-101-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We (GitLab) hit into an issue that somewhere in the middleware chain was throwing `:warden`, which was caught in the wrapping middleware, but `LocalCache::Middleware` was not aware of it. It should look like: ``` ruby result = catch(:warden) do @app.call(env) end ``` Source: https://github.com/hassox/warden/blob/090ed153dbd2f5bf4a1ca672b3018877e21223a4/lib/warden/manager.rb#L35-L37 Using `ensure` could make sure that we would always do the cleanup, and better yet, avoid `rescue Exception` which we all should know that could cause some issues which could be very hard to debug. Please check the discussion thread for more context: https://gitlab.com/gitlab-org/gitlab-ee/merge_requests/1402#note_25128108