Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#19 Add constructors #21

Merged
merged 1 commit into from
Jan 20, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading