Skip to content

Commit 97736d7

Browse files
authored
Merge pull request rails#50498 from skipkayhil/hm-doc-write-options
Document Cache::WriteOptions [ci-skip]
2 parents 2dda042 + f721e71 commit 97736d7

File tree

1 file changed

+10
-0
lines changed
  • activesupport/lib/active_support

1 file changed

+10
-0
lines changed

Diff for: activesupport/lib/active_support/cache.rb

+10
Original file line numberDiff line numberDiff line change
@@ -1072,6 +1072,10 @@ def save_block_result_to_cache(name, key, options)
10721072
end
10731073
end
10741074

1075+
# Enables the dynamic configuration of Cache entry options while ensuring
1076+
# that conflicting options are not both set. When a block is given to
1077+
# ActiveSupport::Cache::Store#fetch, the second argument will be an
1078+
# instance of +WriteOptions+.
10751079
class WriteOptions
10761080
def initialize(options) # :nodoc:
10771081
@options = options
@@ -1089,6 +1093,9 @@ def expires_in
10891093
@options[:expires_in]
10901094
end
10911095

1096+
# Sets the Cache entry's +expires_in+ value. If an +expires_at+ option was
1097+
# previously set, this will unset it since +expires_in+ and +expires_at+
1098+
# cannot both be set.
10921099
def expires_in=(expires_in)
10931100
@options.delete(:expires_at)
10941101
@options[:expires_in] = expires_in
@@ -1098,6 +1105,9 @@ def expires_at
10981105
@options[:expires_at]
10991106
end
11001107

1108+
# Sets the Cache entry's +expires_at+ value. If an +expires_in+ option was
1109+
# previously set, this will unset it since +expires_at+ and +expires_in+
1110+
# cannot both be set.
11011111
def expires_at=(expires_at)
11021112
@options.delete(:expires_in)
11031113
@options[:expires_at] = expires_at

0 commit comments

Comments
 (0)