跳至内容 跳至搜索

启用 Cache 条目选项的动态配置,同时确保不会同时设置冲突的选项。当块被赋予 ActiveSupport::Cache::Store#fetch 时,第二个参数将是 WriteOptions 的一个实例。

方法
E
V

实例公共方法

expires_at()

# File activesupport/lib/active_support/cache.rb, line 1096
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 1103
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 1084
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 1091
def expires_in=(expires_in)
  @options.delete(:expires_at)
  @options[:expires_in] = expires_in
end

version()

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

version=(version)

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