Bug spotted - Cache ttl - java

/**

  • Give a default expiration (or TTL) to the cache to be built.
  • @param expiration the expiration delay in milliseconds.
  • @return this builder for chaining.
    */
    com.couchbase.client.spring.cache.CacheBuilder.withExpirationInMillis(int expiration)

As the documentation specifies that the expiration time should be in milliseconds but the time that it actually takes is in seconds.

Proof: If I give time t in seconds and t is less than 30 days, the entry persists. If I give time t greater than 30 days, the entry is evicted immediately because now time is considered as absolute time i.e time from Unix time.

If I provide time in milliseconds, the behaviour is very unexpected because one can expect unusual behaviour if something expected in seconds is passed in milliseconds.

In short the name of the method and the documentation are misleading.

Yes, you’re absolutely correct. @subhashni: is this in the spring project? I was going to raise an issue, but I’m not quite sure where it goes.

1 Like

It is spring-cache. The project is here https://github.com/couchbaselabs/couchbase-spring-cache, I think there is an issue raised already for this. @rohan.agarwal are you using the 2.x version?

@subhashni

<dependency>
         <groupId>com.couchbase.client</groupId>
         <artifactId>couchbase-spring-cache</artifactId>
         <version>2.0.0</version>
</dependency>

Also this is the only version that maven repository provides.

@rohan.agarwal fixed with a new method - 2.1.0 is released and will sync to maven central in a bit!

1 Like