Class: ActiveSupport::Cache::WriteOptions

Inherits:
Object
  • Object
show all
Defined in:
activesupport/lib/active_support/cache.rb

Overview

Enables the dynamic configuration of Cache entry options while ensuring that conflicting options are not both set. When a block is given to ActiveSupport::Cache::Store#fetch, the second argument will be an instance of WriteOptions.

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ WriteOptions

:nodoc:



1133
1134
1135
# File 'activesupport/lib/active_support/cache.rb', line 1133

def initialize(options) # :nodoc:
  @options = options
end

Instance Method Details

#expires_atObject



1157
1158
1159
# File 'activesupport/lib/active_support/cache.rb', line 1157

def expires_at
  @options[:expires_at]
end

#expires_at=(expires_at) ⇒ Object

Sets the Cache entry’s expires_at value. If an expires_in option was previously set, this will unset it since expires_at and expires_in cannot both be set.



1164
1165
1166
1167
# File 'activesupport/lib/active_support/cache.rb', line 1164

def expires_at=(expires_at)
  @options.delete(:expires_in)
  @options[:expires_at] = expires_at
end

#expires_inObject



1145
1146
1147
# File 'activesupport/lib/active_support/cache.rb', line 1145

def expires_in
  @options[:expires_in]
end

#expires_in=(expires_in) ⇒ Object

Sets the Cache entry’s expires_in value. If an expires_at option was previously set, this will unset it since expires_in and expires_at cannot both be set.



1152
1153
1154
1155
# File 'activesupport/lib/active_support/cache.rb', line 1152

def expires_in=(expires_in)
  @options.delete(:expires_at)
  @options[:expires_in] = expires_in
end

#versionObject



1137
1138
1139
# File 'activesupport/lib/active_support/cache.rb', line 1137

def version
  @options[:version]
end

#version=(version) ⇒ Object



1141
1142
1143
# File 'activesupport/lib/active_support/cache.rb', line 1141

def version=(version)
  @options[:version] = version
end