跳至内容 跳至搜索

允许在 Cache 条目选项的动态配置,同时确保不会同时设置冲突的选项。当为 ActiveSupport::Cache::Store#fetch 提供块时,第二个参数将是 WriteOptions 的实例。

方法
E
V

实例公共方法

expires_at()

# File activesupport/lib/active_support/cache.rb, line 1157
def expires_at
  @options[:expires_at]
end

expires_at=(expires_at)

设置 Cache 条目的 expires_at 值。如果之前设置了 expires_in 选项,则会将其取消设置,因为 expires_atexpires_in 不能同时设置。

# 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_in()

# File activesupport/lib/active_support/cache.rb, line 1145
def expires_in
  @options[:expires_in]
end

expires_in=(expires_in)

设置 Cache 条目的 expires_in 值。如果之前设置了 expires_at 选项,则会将其取消设置,因为 expires_inexpires_at 不能同时设置。

# File activesupport/lib/active_support/cache.rb, line 1152
def expires_in=(expires_in)
  @options.delete(:expires_at)
  @options[:expires_in] = expires_in
end

version()

# File activesupport/lib/active_support/cache.rb, line 1137
def version
  @options[:version]
end

version=(version)

# File activesupport/lib/active_support/cache.rb, line 1141
def version=(version)
  @options[:version] = version
end