The documentation of the org.infinispan.client.hotrod.RemoteCache API is confusing. The Class header explain that lifespan expiration will use Seconds or UnitTime depend on the given value but the methods with lifespan will not reflect that with a hint.
API document (Upstream 9.4
contains the explanation as followed:
Eviction and expiration: Unlike local Cache cache, which allows specifying time values with any granularity (as defined by TimeUnit), HotRod only supports seconds as time units. If a different time unit is used instead, HotRod will transparently convert it to seconds, using TimeUnit.toSeconds(long) method. This might result in loss of precision for values specified as nanos or milliseconds.
Another fundamental difference is in the case of lifespan (naturally does NOT apply for max idle): If number of seconds is bigger than 30 days, this number of seconds is treated as UNIX time and so, represents the number of seconds since 1/1/1970.
But the behavior is different for different ISPN releases. When the specified lifespan value is bigger than 30 days:
- ISPN <=6.2: the value >30days is treated as UNIX time expiry
- ISPN >6.2 <=8.3: the specified value (the maximum is Integer.MAX_VALUE) is treated as lifespan for Hot Rod protocol 2.2 or later.
And as UNIX time expiry for Hot Rod protocol 2.1 or before.
- >8.3: the value >30days is treated as UNIX time expiry regardless of Hot Rod protocol version
According to the API for embedded mode and the method parameters the lifespan should be always treated as seconds, never as UNIX time