跳到內容 跳到搜尋

啟用 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