Class SaApplication

java.lang.Object
cn.dev33.satoken.application.SaApplication
All Implemented Interfaces:
SaGetValueInterface, SaSetValueInterface

public class SaApplication extends Object implements SaSetValueInterface
Application Model,全局作用域的读取值对象。

在应用全局范围内: 存值、取值。数据在应用重启后失效,如果集成了 Redis,则在 Redis 重启后失效。

Since:
1.31.0
Author:
click33
  • Field Details

    • defaultInstance

      public static SaApplication defaultInstance
      默认实例
  • Constructor Details

    • SaApplication

      public SaApplication()
  • Method Details

    • get

      public Object get(String key)
      取值
      Specified by:
      get in interface SaGetValueInterface
      Parameters:
      key - key
      Returns:
    • set

      public SaApplication set(String key, Object value)
      写值
      Specified by:
      set in interface SaSetValueInterface
      Parameters:
      key - 名称
      value - 值
      Returns:
      对象自身
    • delete

      public SaApplication delete(String key)
      删值
      Specified by:
      delete in interface SaSetValueInterface
      Parameters:
      key - 要删除的key
      Returns:
      对象自身
    • set

      public SaApplication set(String key, Object value, long ttl)
      写值
      Parameters:
      key - 名称
      value - 值
      ttl - 有效时间(单位:秒)
      Returns:
      对象自身
    • keys

      public List<String> keys()
      返回当前存入的所有 key
      Returns:
      /
    • clear

      public void clear()
      清空当前存入的所有 key
    • splicingDataKey

      public String splicingDataKey(String key)
      拼接key:当存入一个变量时,应该使用的 key
      Parameters:
      key - 原始 key
      Returns:
      拼接后的 key 值