Class LettuceSimpleRedisClient

java.lang.Object
nablarch.integration.redisstore.lettuce.AbstractLettuceRedisClient
nablarch.integration.redisstore.lettuce.LettuceSimpleRedisClient
All Implemented Interfaces:
Disposable, Initializable, LettuceRedisClient

@Published(tag="architect") public class LettuceSimpleRedisClient extends AbstractLettuceRedisClient implements Initializable
単一の Redis インスタンスに直接接続するためのシンプルな LettuceRedisClient 実装クラス。

このクラスの AbstractLettuceRedisClient.getType() は、識別子 "simple" を返す。

  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected String
    接続するRedisサーバーのURI。
  • Constructor Summary

    Constructors
    Constructor
    Description
    コンストラクタ。
  • Method Summary

    Modifier and Type
    Method
    Description
    protected io.lettuce.core.RedisClient
    RedisClient のインスタンスを生成する。
    protected io.lettuce.core.api.StatefulRedisConnection<byte[],byte[]>
    createConnection(io.lettuce.core.RedisClient client)
    StatefulRedisConnection のインスタンスを生成する。
    void
    del(String key)
    値を削除する。
    void
    Redisサーバーとの接続を閉じる。
    boolean
    指定したキーが存在するか確認する。
    byte[]
    get(String key)
    値を取得する。
    void
    初期化処理を行う。
    void
    pexpire(String key, long milliseconds)
    キーの有効期限を設定する。
    void
    pexpireat(String key, long milliseconds)
    キーの有効期限をUTC時間で設定する
    long
    pttl(String key)
    キーの残りの生存期間を取得する。
    void
    set(String key, byte[] value)
    値を保存する。
    void
    接続するRedisサーバーのURIを設定する。

    Methods inherited from class nablarch.integration.redisstore.lettuce.AbstractLettuceRedisClient

    encodeKey, getType

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • uri

      protected String uri
      接続するRedisサーバーのURI。
  • Constructor Details

    • LettuceSimpleRedisClient

      public LettuceSimpleRedisClient()
      コンストラクタ。
  • Method Details

    • set

      public void set(String key, byte[] value)
      Description copied from interface: LettuceRedisClient
      値を保存する。
      Specified by:
      set in interface LettuceRedisClient
      Parameters:
      key - キー
      value - 値
    • pexpire

      public void pexpire(String key, long milliseconds)
      Description copied from interface: LettuceRedisClient
      キーの有効期限を設定する。
      Specified by:
      pexpire in interface LettuceRedisClient
      Parameters:
      key - キー
      milliseconds - 有効期限(ミリ秒)
    • pexpireat

      public void pexpireat(String key, long milliseconds)
      Description copied from interface: LettuceRedisClient
      キーの有効期限をUTC時間で設定する
      Specified by:
      pexpireat in interface LettuceRedisClient
      Parameters:
      key - キー
      milliseconds - UTC時間で指定された有効期限(ミリ秒)
    • pttl

      public long pttl(String key)
      Description copied from interface: LettuceRedisClient
      キーの残りの生存期間を取得する。

      キーに有効期限が設定されていない場合は -1 を返し、 キーが存在しない場合は -2 を返す。

      Specified by:
      pttl in interface LettuceRedisClient
      Parameters:
      key - キー
      Returns:
      残りの生存期間(ミリ秒)
    • get

      public byte[] get(String key)
      Description copied from interface: LettuceRedisClient
      値を取得する。

      該当するキーが存在しない場合は null を返す。

      Specified by:
      get in interface LettuceRedisClient
      Parameters:
      key - キー
      Returns:
    • del

      public void del(String key)
      Description copied from interface: LettuceRedisClient
      値を削除する。
      Specified by:
      del in interface LettuceRedisClient
      Parameters:
      key - キー
    • exists

      public boolean exists(String key)
      Description copied from interface: LettuceRedisClient
      指定したキーが存在するか確認する。
      Specified by:
      exists in interface LettuceRedisClient
      Parameters:
      key - キー
      Returns:
      キーが存在する場合は true
    • setUri

      public void setUri(String uri)
      接続するRedisサーバーのURIを設定する。

      URIの書式については、Lettuceのドキュメントを参照。

      Parameters:
      uri - 接続するRedisサーバーのURI
    • initialize

      public void initialize()
      初期化処理を行う。

      このメソッドは、 createClient()createConnection(RedisClient) メソッドを使って RedisClientStatefulRedisConnection のインスタンスを生成している。
      これらのインスタンスの設定を任意にカスタマイズしたい場合は、このクラスを継承したサブクラスを作り、 それぞれの create メソッドをオーバーライドすること。

      Specified by:
      initialize in interface Initializable
    • createClient

      protected io.lettuce.core.RedisClient createClient()
      RedisClient のインスタンスを生成する。
      Returns:
      生成された RedisClient
    • createConnection

      protected io.lettuce.core.api.StatefulRedisConnection<byte[],byte[]> createConnection(io.lettuce.core.RedisClient client)
      StatefulRedisConnection のインスタンスを生成する。
      Parameters:
      client - createClient() で生成された RedisClient インスタンス
      Returns:
      生成された StatefulRedisConnection
    • dispose

      public void dispose()
      Description copied from interface: LettuceRedisClient
      Redisサーバーとの接続を閉じる。
      Specified by:
      dispose in interface Disposable
      Specified by:
      dispose in interface LettuceRedisClient