Updated on 2023-10-10 GMT+08:00

JedisConfig

Path

com.roma.apic.livedata.config.v1.JedisConfig

Description

This class is used together with RedisClient to configure the Redis connection.

Example

importClass(com.roma.apic.livedata.client.v1.RedisClient);
importClass(com.roma.apic.livedata.config.v1.JedisConfig);
function execute(data) {
    var config = new JedisConfig();
    config.setIp(["1.1.1.1"]);
    config.setPort(["6379"]);
    config.setMode("SINGLE");
    var redisClient = new RedisClient(config);
    var count = redisClient.get("visit_count")
    if (!count)
    {
        redisClient.put("visit_count", 1);
    }else {
        redisClient.put("visit_count", parseInt(count) + 1);
    }
    return redisClient.get("visit_count");
}

Constructor Details

public JedisConfig()

Constructs a JedisConfig without parameters.

Method List

Returned Type

Method and Description

int

getDatabase()

Obtain the Jedis database. The default value is 0.

String[]

getIp()

Obtain the IP address list of the Redis.

String

getMaster()

Obtain the master name of the Jedis. This parameter is valid when mode is set to MASTER_SLAVE.

int

getMaxAttempts()

Obtain the number of retry times of the Jedis. The default value is 10000.

int

getMaxIdel()

Obtain the maximum number of idle connections in the Jedis connection pool. The default value is 5.

int

getMaxWait()

Obtain the upper limit of the waiting time (in seconds) when the Jedis connection pool is exhausted. The default value is 60.

String

getMode()

Obtain the Jedis type. The value can be SINGLE, CLUSTER, or MASTER_SLAVE.

String

getPassPhrase()

Obtain the password of the Jedis.

String[]

getPort()

Obtain all port numbers.

int

getSoTimeout()

Obtain the read timeout interval of the Jedis. The default value is 600.

int

getTimeout()

Obtain the timeout interval of the Jedis. The default value is 1000.

void

setDatabase(int database)

Set the database of the Jedis.

void

setIp(String[] ip)

Set the IP address.

void

setMaster(String master)

Set the master name of the Jedis. This parameter is valid when mode is set to MASTER_SLAVE.

void

setMaxAttempts(int maxAttempts)

Set the number of retries of the Jedis. The default value is 10000.

void

setMaxIdel(int maxIdel)

Set the maximum number of idle connections in the Jedis connection pool. The default value is 5.

void

setMaxWait(int maxWait)

Set the upper limit of the waiting time when the Jedis connection pool is exhausted. The default value is 60.

void

setMode(String mode)

Set the Jedis type. The value can be SINGLE, CLUSTER, or MASTER_SLAVE.

void

setPassPhrase(String passPhrase)

Set the password of the Jedis.

void

setPort(String[] port)

Set the port number.

void

setSoTimeout(int soTimeout)

Set the read timeout interval of the Jedis.

void

setTimeout(int timeout)

Set the timeout interval of the Jedis.

Method Details

  • public int getDatabase()

    Obtain the Redis database. The default value is 0.

    Returns

    Database.

  • public String[] getIp()

    Obtain all IP addresses.

    Returns

    String array of IP addresses.

  • public String getMaster()

    Obtain the master name of the Redis. This parameter is valid when mode is set to MASTER_SLAVE.

    Returns

    Master name.

  • public int getMaxAttempts()

    Obtain the number of retry times of the Redis. The default value is 10000.

    Returns

    Number of retry times.

  • public int getMaxIdel()

    Obtain the maximum number of idle connections in the Jedis connection pool. The default value is 5.

    Returns

    Maximum number of idle connections in the connection pool.

  • public int getMaxWait()

    Obtain the upper limit of the waiting time (in seconds) when the Jedis connection pool is exhausted. The default value is 60.

    Returns

    Upper limit of the waiting time when the connection pool is exhausted.

  • public String getMode()

    Obtain the Redis type. The value can be SINGLE, CLUSTER, or MASTER_SLAVE.

    Returns

    Redis type.

  • public String getPassPhrase()

    Obtain the password of the Redis.

    Returns

    Redis password.

  • public String[] getPort()

    Obtain all port numbers.

    Returns

    String array of port numbers.

  • public int getSoTimeout()

    Obtain the read timeout interval (in seconds) of the Jedis. The default value is 600.

    Returns

    Value of soTimeout.

  • public int getTimeout()

    Obtain the timeout interval (in seconds) of the Jedis. The default value is 1000.

    Returns

    Timeout interval.

  • public void setDatabase(int database)

    Set the database of the Redis.

    Input Parameter

    database indicates a database.

  • public void setIp(String[] ip)

    Set the IP address.

    Input Parameter

    ip indicates an IP address.

  • public void setMaster(String master)

    Set the master name of the Redis. This parameter is valid when mode is set to MASTER_SLAVE.

    Input Parameter

    master indicates the master name of the Redis.

  • public void setMaxAttempts(int maxAttempts)

    Set the number of retries of the Jedis.

    Input Parameter

    maxAttempts indicates the number of retries.

  • public void setMaxIdel(int maxIdel)

    Set the maximum number of idle connections in the Jedis connection pool. The default value is 5.

    Input Parameter

    maxIdel indicates the maximum number of idle connections in the connection pool.

  • public void setMaxWait(int maxWait)

    Set the upper limit of the waiting time (in seconds) when the Jedis connection pool is exhausted. The default value is 60.

    Input Parameter

    maxWait indicates the upper limit of the waiting time when the connection pool is exhausted.

  • public void setMode(String mode)

    Set the Redis type. The value can be SINGLE, CLUSTER, or MASTER_SLAVE.

    Input Parameter

    mode indicates the type.

  • public void setPassPhrase(String passPhrase)

    Set the password of the Redis.

    Input Parameter

    passPhrase indicates the password.

  • public void setPort(String[] port)

    Set the port number.

    Input Parameter

    port indicates the port number.

  • public void setSoTimeout(int soTimeout)

    Set the read timeout interval (in seconds) of the Jedis. The default value is 600.

    Input Parameter

    soTimeout indicates the read timeout interval.

  • public void setTimeout(int timeout)

    Set the timeout interval of the Jedis.

    Input Parameter

    timeout indicates the timeout duration, in seconds.