Skip to content

Commit

Permalink
Merge pull request #21 from IlyaLisov/#19
Browse files Browse the repository at this point in the history
#19 Add constructors
  • Loading branch information
IlyaLisov authored Jan 20, 2024
2 parents 386987b + b5c6604 commit 7477ecb
Showing 1 changed file with 49 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import io.github.ilyalisov.jwt.config.redis.RedisSchema;
import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisPool;
import redis.clients.jedis.JedisPoolConfig;

/**
* Implementation of TokenStorage based on Redis.
Expand All @@ -22,7 +23,7 @@ public class RedisTokenStorageImpl implements TokenStorage {
private final RedisSchema redisSchema;

/**
* Creates an object with provided JedisPool and DefaultRedisSchema.
* Creates an object.
*
* @param jedisPool JedisPool object
*/
Expand All @@ -34,7 +35,7 @@ public RedisTokenStorageImpl(
}

/**
* Creates an object with provided JedisPool and RedisSchema.
* Creates an object.
*
* @param jedisPool JedisPool object
* @param redisSchema RedisSchema object
Expand All @@ -47,6 +48,52 @@ public RedisTokenStorageImpl(
this.redisSchema = redisSchema;
}

/**
* Creates an object.
*
* @param host Redis host
* @param port Redis port
*/
public RedisTokenStorageImpl(
final String host,
final int port
) {
JedisPoolConfig config = new JedisPoolConfig();
config.setJmxEnabled(false);
this.jedisPool = new JedisPool(
config,
host,
port
);
this.redisSchema = new DefaultRedisSchema();
}

/**
* Creates an object.
*
* @param host Redis host
* @param port Redis port
* @param user Redis username
* @param password Redis password
*/
public RedisTokenStorageImpl(
final String host,
final int port,
final String user,
final String password
) {
JedisPoolConfig config = new JedisPoolConfig();
config.setJmxEnabled(false);
this.jedisPool = new JedisPool(
config,
host,
port,
user,
password
);
this.redisSchema = new DefaultRedisSchema();
}

@Override
public void save(
final String token,
Expand Down

0 comments on commit 7477ecb

Please sign in to comment.