-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Julien Ruaux
committed
Jun 6, 2023
1 parent
e3c28ca
commit 1c2a8c8
Showing
13 changed files
with
137 additions
and
98 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 0 additions & 48 deletions
48
core/redis-smart-cache-jdbc/src/main/java/com/redis/smartcache/jdbc/RedisResultSetCache.java
This file was deleted.
Oops, something went wrong.
42 changes: 42 additions & 0 deletions
42
core/redis-smart-cache-jdbc/src/main/java/com/redis/smartcache/jdbc/RedisRowSetCache.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package com.redis.smartcache.jdbc; | ||
|
||
import java.sql.SQLException; | ||
import java.time.Duration; | ||
|
||
import javax.sql.RowSet; | ||
|
||
import com.redis.lettucemod.util.RedisModulesUtils; | ||
|
||
import io.lettuce.core.AbstractRedisClient; | ||
import io.lettuce.core.api.StatefulRedisConnection; | ||
import io.lettuce.core.codec.RedisCodec; | ||
|
||
public class RedisRowSetCache implements RowSetCache { | ||
|
||
private final StatefulRedisConnection<String, RowSet> connection; | ||
|
||
public RedisRowSetCache(AbstractRedisClient client, RedisCodec<String, RowSet> codec) { | ||
this.connection = RedisModulesUtils.connection(client, codec); | ||
} | ||
|
||
@Override | ||
public RowSet get(String key) { | ||
return connection.sync().get(key); | ||
} | ||
|
||
@Override | ||
public void put(String key, RowSet rowSet) throws SQLException { | ||
connection.sync().set(key, rowSet); | ||
} | ||
|
||
@Override | ||
public void put(String key, RowSet rowSet, Duration ttl) throws SQLException { | ||
connection.sync().psetex(key, ttl.toMillis(), rowSet); | ||
} | ||
|
||
@Override | ||
public void close() { | ||
connection.close(); | ||
} | ||
|
||
} |
11 changes: 7 additions & 4 deletions
11
...redis/smartcache/jdbc/ResultSetCache.java → ...om/redis/smartcache/jdbc/RowSetCache.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,21 @@ | ||
package com.redis.smartcache.jdbc; | ||
|
||
import java.sql.ResultSet; | ||
import java.sql.SQLException; | ||
import java.time.Duration; | ||
|
||
public interface ResultSetCache extends AutoCloseable { | ||
import javax.sql.RowSet; | ||
|
||
public interface RowSetCache extends AutoCloseable { | ||
|
||
/** | ||
* | ||
* @param key the unique key to get the ResultSet for. | ||
* @return RowSet that was retrieved from cache or null if none | ||
*/ | ||
ResultSet get(String key); | ||
RowSet get(String key); | ||
|
||
void put(String key, RowSet rowSet) throws SQLException; | ||
|
||
ResultSet put(String key, Duration ttl, ResultSet resultSet) throws SQLException; | ||
void put(String key, RowSet rowSet, Duration ttl) throws SQLException; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.