By default, Dalli has two fallbacks if no server addresses are given:
- $MEMCACHE_SERVERS
- "127.0.0.1:11211"
However, MemCacheStore does its own check for addresses, and falls back
to "localhost:11211" if none are present.
This can lead to bugs in migrations from the deprecated :dalli_store
(provided by the Dalli) to :mem_cache_store:
```diff
-config.cache_store = :dalli_store # could be implicitly relying on $MEMCACHE_SERVERS
+config.cache_store = :mem_cache_store # ignores $MEMCACHE_SERVERS
```
By removing our own fallback and simply passing `nil` to Dalli::Client,
we get its fallback logic for free. Tests are added so we can detect if
this ever changes.
In redis cache store, options to `fetch_multi` are passed correctly to
`write_multi` but not to `read_multi`. This causes cache always to be missed
when passing `namespace` option to it.
- Disables Dalli compression in MemCacheStore.
- Fixes issue where redundant compression in Dalli can cause values to
either be compressed twice, or compressed when they fall below the
specified compression threshold.
- Fixes issue where reads with raw: true using redis or memcached cache
store, will compress values on reads.
- Should speed up raw cache reads by preventing unnecessary cpu intensive
operation.
In the past, we sometimes hit missing `Symbol#start_with?` and
`Symbol#end_with?`.
63256bc5d7a8e812964d
So I proposed `Symbol#start_with?` and `Symbol#end_with?` to allow duck
typing that methods for String and Symbol, then now it is available in
Ruby 2.7.
https://bugs.ruby-lang.org/issues/16348
Using `String#starts_with?` and `String#ends_with?` could not be gained
that conveniency, so it is preferable to not use these in the future.
Calling `#tagged` without a block now returns a new logger with the tags
applied. This is useful for when you want to tag an individual log line,
rather than an entire request.
`(1..10).cover?(5..3)` now returns `false`, as it does in plain Ruby. Previously this returned `true`.
Also update `#include?` and `#===` behavior to match.
Add Date and Time `#yesterday?` and `#tomorrow?` alongside `#today?`.
Aliased to `#prev_day?` and `#next_day?` to match the existing `#prev/next_day` methods.
This allows `pick` to be called on an object that could either be an
enumerable or a relation.
Also clarify the documentation for `Enumerable#pluck`, and add an
example of plucking multiple keys to the core extensions guide.
- The `halted_callback_hook` method is called whenever the
`terminator` halt the callback execution.
Usually, this translate to when a `before` callback throw
an `:abort`.
<details>
<summary> Example </summary>
```ruby
class Foo
include ActiveSupport::Callbacks
define_callbacks :save
set_callback(:save, :before) { throw(:abort) }
def run
run_callbacks(:save) do
'hello'
end
end
def halted_callback_hook(filter)
# filter is the proc passed to `set_callback` above
end
end
```
</details>
### Problem
When a class has multiple callbacks, (i.e. `save`, `validate` ...),
it's impossible to tell in the halted_callback_hook which type of
callback halted the execution.
This is useful to take different action based on the callback.
<details>
<summary> Use Case </summary>
```ruby
class Foo
include ActiveSupport::Callbacks
define_callbacks :save
define_callbacks :validate
set_callback(:save, :before) { throw(:abort) }
set_callback(:validate, :before) { throw(:abort) }
def run
run_callbacks(:validate) do
...
end
run_callbacks(:save) do
...
end
end
def halted_callback_hook(filter)
Rails.logger.warn("Couldn't save the record, the ??? callback halted the execution")
end
end
```
</details>
### Solution
Allow `halted_callback_hook` to receive a second argument which is
the name of the callback being run.
Support handling a `round_mode` in `ActiveSupport::NumberHelper::RoundingHelper`
Add default value to locale file
Update inline documentation with new parameter option
Update CHANGELOG
Add round_mode examples to all the tests
Add I18n test
Simplify logic
Further simpification
It converts the week part into days and removes it from the final result.
```
duration = ActiveSupport::Duration.build(1000000) # 1 week, 4 days, 13 hours, 46 minutes, and 40.0 seconds
duration_iso = duration.iso8601 # P11DT13H46M40S
ActiveSupport::Duration.parse(duration_iso) # 11 days, 13 hours, 46 minutes, and 40 seconds
```