1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Aesthetics

This commit is contained in:
David Heinemeier Hansson 2013-11-03 12:39:47 -08:00
parent 50b7d21ed7
commit 1c35f9331c

View file

@ -88,7 +88,6 @@ module ActiveSupport
end
private
def retrieve_cache_key(key)
case
when key.respond_to?(:cache_key) then key.cache_key
@ -153,7 +152,6 @@ module ActiveSupport
# or +write+. To specify the threshold at which to compress values, set the
# <tt>:compress_threshold</tt> option. The default threshold is 16K.
class Store
cattr_accessor :logger, :instance_writer => true
attr_reader :silence, :options
@ -385,6 +383,7 @@ module ActiveSupport
# Options are passed to the underlying cache implementation.
def write(name, value, options = nil)
options = merged_options(options)
instrument(:write, name, options) do
entry = Entry.new(value, options)
write_entry(namespaced_key(name, options), entry, options)
@ -396,6 +395,7 @@ module ActiveSupport
# Options are passed to the underlying cache implementation.
def delete(name, options = nil)
options = merged_options(options)
instrument(:delete, name) do
delete_entry(namespaced_key(name, options), options)
end
@ -406,6 +406,7 @@ module ActiveSupport
# Options are passed to the underlying cache implementation.
def exist?(name, options = nil)
options = merged_options(options)
instrument(:exist?, name) do
entry = read_entry(namespaced_key(name, options), options)
(entry && !entry.expired?) || false
@ -585,6 +586,7 @@ module ActiveSupport
result = instrument(:generate, name, options) do |payload|
yield(name)
end
write(name, result, options)
result
end
@ -608,6 +610,7 @@ module ActiveSupport
else
@value = value
end
@created_at = Time.now.to_f
@expires_in = options[:expires_in]
@expires_in = @expires_in.to_f if @expires_in
@ -658,6 +661,7 @@ module ActiveSupport
# serialize entries to protect against accidental cache modifications.
def dup_value!
convert_version_4beta1_entry! if defined?(@v)
if @value && !compressed? && !(@value.is_a?(Numeric) || @value == true || @value == false)
if @value.is_a?(String)
@value = @value.dup
@ -672,8 +676,10 @@ module ActiveSupport
if value && options[:compress]
compress_threshold = options[:compress_threshold] || DEFAULT_COMPRESS_LIMIT
serialized_value_size = (value.is_a?(String) ? value : Marshal.dump(value)).bytesize
return true if serialized_value_size >= compress_threshold
end
false
end
@ -696,10 +702,12 @@ module ActiveSupport
@value = @v
remove_instance_variable(:@v)
end
if defined?(@c)
@compressed = @c
remove_instance_variable(:@c)
end
if defined?(@x) && @x
@created_at ||= Time.now.to_f
@expires_in = @x - @created_at