Using Age Validator

A recurring use case is to save the data in cache only for a period of time. To address this issue Livebox comes with a built-in AgeValidator that invalidates data after a certain amount of time has passed.

// 2 minutes TTL(time to live)
Validator<UsersRes> ageValidator = AgeValidator.create(TimeUnit.MINUTES.toMillis(2));

// Add to data source
.addSource(Sources.DISK_PERSISTENT, persistentDiskValidator)

In the above example the data is only valid for 2 minutes.

Last updated