Skip to content

interface IDistributedCache

cangjie
public interface IDistributedCache

功能:定义分布式缓存的基础读写操作。

成员概览

成员功能
func get(String)获取指定键对应的缓存值。
func refresh(String)刷新指定键对应缓存项的访问状态。
func remove(String)删除指定键对应的缓存项。
func set(String, Array<Byte>)使用默认缓存选项写入二进制值。
func set(String, Array<Byte>, DistributedCacheEntryOptions)使用指定缓存选项写入二进制值。
func getString(String)获取指定键对应的字符串缓存值。
func setString(String, String)使用默认缓存选项写入字符串值。
func setString(String, String, DistributedCacheEntryOptions)使用指定缓存选项写入字符串值。

func get(String)

cangjie
func get(key: String): ?Array<Byte>

功能:获取指定键对应的缓存值。

参数:

  • key: String - 缓存项的键。

返回值:

  • ?Array<Byte> - 返回缓存中的二进制值;如果键不存在则返回 None。

func refresh(String)

cangjie
func refresh(key: String): Unit

功能:刷新指定键对应缓存项的访问状态。

参数:

  • key: String - 缓存项的键。

返回值:

  • Unit

func remove(String)

cangjie
func remove(key: String): Unit

功能:删除指定键对应的缓存项。

参数:

  • key: String - 缓存项的键。

返回值:

  • Unit

func set(String, Array<Byte>)

cangjie
func set(key: String, value: Array<Byte>): Unit

功能:使用默认缓存选项写入二进制值。

参数:

  • key: String - 缓存项的键。
  • value: Array<Byte> - 要写入的二进制值。

返回值:

  • Unit

func set(String, Array<Byte>, DistributedCacheEntryOptions)

cangjie
func set(key: String, value: Array<Byte>, options: DistributedCacheEntryOptions): Unit

功能:使用指定缓存选项写入二进制值。

参数:

  • key: String - 缓存项的键。
  • value: Array<Byte> - 要写入的二进制值。
  • options: DistributedCacheEntryOptions - 缓存条目的过期配置。

返回值:

  • Unit

func getString(String)

cangjie
func getString(key: String): ?String

功能:获取指定键对应的字符串缓存值。

参数:

  • key: String - 缓存项的键。

返回值:

  • ?String - 返回缓存中的字符串值;如果键不存在则返回 None。

func setString(String, String)

cangjie
func setString(key: String, value: String): Unit

功能:使用默认缓存选项写入字符串值。

参数:

  • key: String - 缓存项的键。
  • value: String - 要写入的字符串值。

返回值:

  • Unit

func setString(String, String, DistributedCacheEntryOptions)

cangjie
func setString(key: String, value: String, options: DistributedCacheEntryOptions): Unit

功能:使用指定缓存选项写入字符串值。

参数:

  • key: String - 缓存项的键。
  • value: String - 要写入的字符串值。
  • options: DistributedCacheEntryOptions - 缓存条目的过期配置。

返回值:

  • Unit