Releases: redis/jedis
5.2.0-beta1
What's new
This release supports server-assisted, client-side caching, and is currently beta grade.
Client-side caching is available within UnifiedJedis, JedisPooled, JedisCluster, etc classes via implementation of ClientSideCache class, with only RESP3 protocol. It is recommended to use a ClientSideCache implementation with TTL (time-to-live). We have included two implementations based on Google Guava and Caffeine libraries.
How to try Client-Side Caching
- Install Jedis 5.2.0-beta1
- Choose and install a caching library: Google Guava or Caffeine
- Use the following code example to get started:
import redis.clients.jedis.*;
import redis.clients.jedis.csc.*;
class CacheExample {
public static void main() {
HostAndPort node = HostAndPort.from("localhost:6379");
JedisClientConfig clientConfig = DefaultJedisClientConfig.builder()
.resp3() // RESP3 protocol
//.user("myuser") // Redis server username (optional)
//.password("mypass") // Redis user's password (optional)
.build();
ClientSideCache clientSideCache;
// Uncomment one of the following lines to use the corresponding cache backend
// GuavaClientSideCache clientSideCache = GuavaClientSideCache.builder().maximumSize(10_000).ttl(100).build();
// CaffeineClientSideCache clientSideCache = CaffeineClientSideCache.builder().maximumSize(10_000).ttl(100).build();
UnifiedJedis client = new UnifiedJedis(node, clientConfig, clientSideCache);
// JedisPooled client = new JedisPooled(node, clientConfig, clientSideCache);
// JedisCluster client = new JedisCluster(Collections.singleton(node), clientConfig, clientSideCache);
client.set("foo", "bar");
client.get("foo");
client.get("foo"); // cache hit
client.del("foo");
client.close();
}
}
It is highly recommended to use a ClientSideCache implementation with TTL.
Both of our provided GuavaClientSideCache and CaffeineClientSideCache have TTL support and use a default value when not set. It is discouraged to use ttl(0)
in these.
It is also a good idea to keep the idle connections busy to get more and updated notifications. It can be done easily using pool config:
GenericObjectPoolConfig<Connection> poolConfig = new ConnectionPoolConfig();
poolConfig.setTestWhileIdle(true); // ConnectionPoolConfig by default does this.
// It is still shown here for better understanding.
This pool config can be used as follows:
JedisPooled client = new JedisPooled(node, clientConfig, clientSideCache, poolConfig);
JedisCluster client = new JedisCluster(Collections.singleton(node), clientConfig, clientSideCache, poolConfig);
It is possible to limit or ignore commands and/or keys for client side caching. For example, if we want to ignore some keys based on their prefix, we can define a ClientSideCacheable:
final String IGNORE_PREFIX = "PREFIX_TO_IGNORE";
ClientSideCacheable isCacheable = new ClientSideCacheable() {
@Override
public boolean isCacheable(ProtocolCommand command, Object... keys) {
for (String key : (String[]) keys) { // assuming we'll only execute methods with String keys
if (key.startsWith(IGNORE_PREFIX)) {
return false;
}
}
return true;
}
};
This ClientSideCacheable can be a parameter for ClientSideCache. In our provided implementations, it can be:
GuavaClientSideCache clientSideCache = GuavaClientSideCache.builder().cacheable(isCacheable).build();
CaffeineClientSideCache clientSideCache = CaffeineClientSideCache.builder().cacheable(isCacheable).build();
It is also possible to create client-side caching enabled client object using URL/URI with proper query params. Supported params are:
cache_lib
(caching library) - required; can be eitherguava
orcaffeine
cache_max_size
(maximum no of commands) - optionalcache_ttl
(time-to-live, in seconds) - optional
For example:
JedisPooled client = new JedisPooled("redis://myuser:mypass@localhost:6379/?cache_lib=guava&cache_max_size=10000&cache_ttl=100");
5.1.2
5.2.0-alpha3
This release provides support for server-assisted, client-side caching, and is currently alpha grade.
Client-side caching is available within UnifiedJedis, JedisPooled, JedisCluster, etc classes via implementation of ClientSideCache class, with RESP3 only. It is recommended a ClientSideCache implementation with TTL (time-to-live). We have included two implementations based on Google Guava and Caffeine libraries.
class CacheExample {
public static void main() {
HostAndPort hnp = HostAndPort.from("localhost:6379");
JedisClientConfig config = DefaultJedisClientConfig.builder()
.resp3() // RESP3 protocol
.password("foobared")
.build();
ClientSideCache csc;
// ClientSideCache csc = GuavaCSC.builder().maximumSize(1000).ttl(100).build();
// ClientSideCache csc = CaffeineCSC.builder().maximumSize(1000).ttl(100).build();
UnifiedJedis client = new UnifiedJedis(hnp, config, csc);
// JedisPooled client = new JedisPooled(hnp, config, csc);
// JedisCluster client = new JedisCluster(Collections.singleton(hnp), config, csc);
client.set("foo", "bar");
client.get("foo");
client.get("foo"); // cache hit
client.del("foo");
client.close();
}
}
4.4.7
Changes
π New Features
- Added HSET variants to ease complex objects (#3605)
π Bug Fixes
- Avoid NPE in MultiNodePipelineBase.java (#3697)
- Direct FT.CREATE to proper node in LIGHT search mode (#3593)
π§° Maintenance
- Use simple version of HSET (#3587)
- Deprecate RediSearchUtil#ToByteArray
Contributors
We'd like to thank all the contributors who worked on this release!
@sazzad16 and @stillerrr
5.1.1
Changes
π Bug Fixes
- Avoid NPE in MultiNodePipelineBase.java (#3697)
- Fix probable missing (RESP3) protocol processing (#3692)
- Use circuit breaker fallback exception list (#3664)
π§° Maintenance
- Access Reducer attributes (#3637)
- Replace deprecated set-output command with environment file (#3622)
- Bump jackson.version from 2.16.0 to 2.16.1 (#3666)
- Bump jackson databind and jsr310 to 2.16.0 (#3655)
- Bump com.kohlschutter.junixsocket:junixsocket-core from 2.8.1 to 2.8.3 (#3647)
Contributors
We'd like to thank all the contributors who worked on this release!
@dependabot, @dependabot[bot], @jongwooo, @sazzad16 and @stillerrr
5.2.0-alpha2
This release provides support for server-assisted, client-side caching, and is currently alpha grade. Currently it is supported on top of the Jedis class, and will be merged to Jedis/UnifiedJedis classes via configuration parameters.
Client-side caching is available through JedisClientSideCache class, with RESP3 only.
Note: The process of ensuring the last invalidation when there is none, is still time consuming; it is suggested to use a smaller socket timeout if this is an issue. We have started with only GET command at this moment.
import redis.clients.jedis.HostAndPort;
import redis.clients.jedis.JedisClientConfig;
import redis.clients.jedis.DefaultJedisClientConfig;
import redis.clients.jedis.JedisClientSideCache;
class CacheExample {
public static void main() {
HostAndPort hnp = HostAndPort.from("localhost:6379");
JedisClientConfig config = DefaultJedisClientConfig.builder()
.resp3() // RESP3 protocol
.socketTimeoutMillis(20) // smaller socket timeout
.password("foobared")
.build();
JedisClientSideCache jCache = new JedisClientSideCache(hnp, config);
jCache.set("foo", "bar");
jCache.get("foo");
jCache.get("foo"); // cache hit
jCache.del("foo");
jCache.close();
}
}
5.2.0-alpha1
Re-released as 5.2.0-alpha2.
5.1.0
Changes
π₯ Breaking Changes
- Adding Pipeline & Transaction with failover to multi cluster (#3602)
- Move JedisMetaInfo into parent package and made private (#3590)
- Encode map in encoded object (#3555)
π§ͺ Experimental Features
- Pipeline & Transaction with failover to multi cluster (#3602)
- Support GEOSHAPE field type in RediSearch (#3561)
- Re-add FT.DROPINDEX and FT.ALTER in pipeline (#3549)
π New Features
- Add CLUSTER SHARDS command support (#2984) (#3598)
- Added HSET variants to ease complex objects (#3605)
- Introducing periodic topology mechanism for JedisCluster (#3596)
- Support RESET command (#3015)
- Broadcast FUNCTION LOAD command methods (#3557)
- Feature: Triggers and functions commands (#3531)
- Escape utils for RediSearch queries (#3544)
- Address further CLIENT SETINFO suffix rules (#3536)
- Extend CLIENT SETINFO support (#3509)
π Bug Fixes
- Direct FT.CREATE to proper node in LIGHT search mode (#3593)
- Fix binary variants of XRANGE and XREAD commands (#3571)
π§° Maintenance
- Use simple version of HSET (#3587)
- Linking to Redis learning resources (#3583)
- Added support for releasing minor version snapshots (#3578)
- Allow getting schema field name (#3576)
- Encoded map in encoded object (#3555)
- Improved Triggers and functions tests (#3554)
- Different variable names for json v1 and v2 interfaces (#3553)
- Fixed Search/Gears test regression (#3552)
- Improved Triggers and functions commands (#3551)
- Added JavaDoc for GeoRadiusResponse (#3542)
- Disabling doctests on tag (#3524)
- Move pom.properties file into redis.clients.jedis package (#3589)
- Bump org.json:json from 20230618 to 20231013 (#3586)
- Bump org.apache.commons:commons-pool2 from 2.11.1 to 2.12.0 (#3565)
- Bump junixsocket-core to 2.8.1 (#3573)
- Bump org.apache.maven.plugins:maven-javadoc-plugin from 3.5.0 to 3.6.0 (#3539)
- Bump mockito-inline from 3.12.4 to 4.11.0 (#3232)
- Bump org.apache.maven.plugins:maven-surefire-plugin from 3.2.1 to 3.2.2 (#3611)
- Bump org.apache.maven.plugins:maven-javadoc-plugin from 3.6.0 to 3.6.2 (#3612)
- Bump org.apache.maven.plugins:maven-surefire-plugin from 3.1.2 to 3.2.1 (#3600)
Contributors
We'd like to thank all the contributors who worked on this release!
@bsbodden, @chayim, @dependabot, @dependabot[bot], @ihaohong, @sazzad16, @wormogig and @yangbodong22011
5.0.2
4.4.6
Changes
π Bug Fixes
- Fix SORTABLE argument when creating a Search index using FT.CREATE (#3584)
- Fix binary variants of XRANGE and XREAD commands (#3571)
π New Features
- Added broadcast support for FUNCTION LOAD methods (#3557)
- Support GEOSHAPE field type in RediSearch (#3561)
- Support TOPK.LIST with WITHCOUNT option (#3495)