All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.mageddo.commons.caching.internal.WrapperIndex Maven / Gradle / Ivy

The newest version!
package com.mageddo.commons.caching.internal;

import java.time.LocalDateTime;
import java.util.Comparator;

import lombok.EqualsAndHashCode;
import lombok.Value;

@Value
@EqualsAndHashCode(of = "key")
public class WrapperIndex {

  private String key;
  private Wrapper wrapper;

  public static WrapperIndex of(String key, Wrapper w) {
    return new WrapperIndex(key, w);
  }

  public static Comparator leastUsedIndex() {
    return Comparator.comparingInt(WrapperIndex::getAccesses);
  }

  public static Comparator expirationIndex() {
    return Comparator.comparing(WrapperIndex::willExpireAt);
  }

  int getAccesses() {
    return this.wrapper.getAccesses();
  }

  LocalDateTime willExpireAt(){
    return this.wrapper.getExpiresAt();
  }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy