@@ -170,11 +170,6 @@ def retrieve_store_class(store)
170
170
# cache.namespace = -> { @last_mod_time } # Set the namespace to a variable
171
171
# @last_mod_time = Time.now # Invalidate the entire cache by changing namespace
172
172
#
173
- # Cached data larger than 1kB are compressed by default. To turn off
174
- # compression, pass <tt>compress: false</tt> to the initializer or to
175
- # individual +fetch+ or +write+ method calls. The 1kB compression
176
- # threshold is configurable with the <tt>:compress_threshold</tt> option,
177
- # specified in bytes.
178
173
class Store
179
174
cattr_accessor :logger , instance_writer : true
180
175
@@ -283,32 +278,6 @@ def mute
283
278
# cache.exist?('foo') # => true
284
279
# cache.exist?('bar') # => false
285
280
#
286
- #
287
- # Setting <tt>compress: false</tt> disables compression of the cache entry.
288
- #
289
- # Setting <tt>:expires_in</tt> will set an expiration time on the cache.
290
- # All caches support auto-expiring content after a specified number of
291
- # seconds. This value can be specified as an option to the constructor
292
- # (in which case all entries will be affected), or it can be supplied to
293
- # the +fetch+ or +write+ method to affect just one entry.
294
- # <tt>:expire_in</tt> and <tt>:expired_in</tt> are aliases for
295
- # <tt>:expires_in</tt>.
296
- #
297
- # cache = ActiveSupport::Cache::MemoryStore.new(expires_in: 5.minutes)
298
- # cache.write(key, value, expires_in: 1.minute) # Set a lower value for one entry
299
- #
300
- # Setting <tt>:expires_at</tt> will set an absolute expiration time on the cache.
301
- # All caches support auto-expiring content after a specified number of
302
- # seconds. This value can only be supplied to the +fetch+ or +write+ method to
303
- # affect just one entry.
304
- #
305
- # cache = ActiveSupport::Cache::MemoryStore.new
306
- # cache.write(key, value, expires_at: Time.now.at_end_of_hour)
307
- #
308
- # Setting <tt>:version</tt> verifies the cache stored under <tt>name</tt>
309
- # is of the same version. nil is returned on mismatches despite contents.
310
- # This feature is used to support recyclable cache keys.
311
- #
312
281
# Setting <tt>:race_condition_ttl</tt> is very useful in situations where
313
282
# a cache entry is used very frequently and is under heavy load. If a
314
283
# cache expires and due to heavy load several different processes will try
@@ -517,9 +486,39 @@ def fetch_multi(*names)
517
486
end
518
487
end
519
488
520
- # Writes the value to the cache, with the key.
489
+ # Writes the value to the cache with the key. The value must be supported
490
+ # by the +coder+'s +dump+ and +load+ methods.
521
491
#
522
- # Options are passed to the underlying cache implementation.
492
+ # By default, cache entries larger than 1kB are compressed. Compression
493
+ # allows more data to be stored in the same memory footprint, leading to
494
+ # fewer cache evictions and higher hit rates.
495
+ #
496
+ # ==== Options
497
+ #
498
+ # * <tt>compress: false</tt> - Disables compression of the cache entry.
499
+ #
500
+ # * +:compress_threshold+ - The compression threshold, specified in bytes.
501
+ # \Cache entries larger than this threshold will be compressed. Defaults
502
+ # to +1.kilobyte+.
503
+ #
504
+ # * +:expires_in+ - Sets a relative expiration time for the cache entry,
505
+ # specified in seconds. +:expire_in+ and +:expired_in+ are aliases for
506
+ # +:expires_in+.
507
+ #
508
+ # cache = ActiveSupport::Cache::MemoryStore.new(expires_in: 5.minutes)
509
+ # cache.write(key, value, expires_in: 1.minute) # Set a lower value for one entry
510
+ #
511
+ # * +:expires_at+ - Sets an absolute expiration time for the cache entry.
512
+ #
513
+ # cache = ActiveSupport::Cache::MemoryStore.new
514
+ # cache.write(key, value, expires_at: Time.now.at_end_of_hour)
515
+ #
516
+ # * +:version+ - Specifies a version for the cache entry. When reading
517
+ # from the cache, if the cached version does not match the requested
518
+ # version, the read will be treated as a cache miss. This feature is
519
+ # used to support recyclable cache keys.
520
+ #
521
+ # Other options will be handled by the specific cache store implementation.
523
522
def write ( name , value , options = nil )
524
523
options = merged_options ( options )
525
524
0 commit comments