跳到內容 跳到搜尋

啟用 Cache 條目選項的動態配置,同時確保沒有同時設定衝突的選項。如果給 ActiveSupport::Cache::Store#fetch 一個區塊,第二個參數將是 WriteOptions 的一個執行個體。

方法
E
V

執行個體公共方法

expires_at()

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

version()

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

version=(version)

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