Skip to content

Instantly share code, notes, and snippets.

@Override
@Cacheable(value = "invoicesCache", key = "#invoiceId")
public Invoice getInvoice(String invoiceId) {
// Get data from backend service
}
@Override
@CacheEvict(value = "invoicesCache", key = "#invoiceId")
public void evictInvoicesCache(String invoiceId) {
<cache name="invoicesCache" eternal="false" maxElementsInMemory="1000" overflowToDisk="false"
diskPersistent="false" timeToIdleSeconds="0" timeToLiveSeconds="3600" memoryStoreEvictionPolicy="LRU"/>
@Component
public class MqttComponentPurePahoImpl implements MqttComponent {
private final String mqttUrl;
private final String mqttUser;
private final String mqttPassword;
private final String displayNameNode;
private final ObjectWriter objectWriter;
private MqttClient mqttClient;
// Snippet of code used to evict invoices cache when mqtt messages arrive. We assume we have an mqttComponent and
// an invoiceService correctly defined in the current scope
mqttComponent.subscribeToTopicWithEmptyPayload("caches/invoices/+/evict",evictInvoiceCache(),1);
// ...
private Function<String,Void> evictInvoiceCache() {
return topic->{
import java.util.Calendar;
import lombok.Builder;
import lombok.Value;
@Builder
@Value
public class JacksonExample {
private String fieldOne;
private String fieldTwo;
import java.util.Calendar;
import lombok.Builder;
import lombok.Value;
import com.fasterxml.jackson.annotation.JsonIgnore;
@Builder
@Value
import java.util.Calendar;
import lombok.Builder;
import lombok.Value;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.databind.PropertyNamingStrategy;
import com.fasterxml.jackson.databind.annotation.JsonNaming;
public enum JacksonExampleEnum {
OPTION_1("0", "0"), OPTION_2("1", "1");
private String a;
private String b;
JacksonTestEnum(String a, String b) {
this.a = a;
this.b = b;
}
import java.util.Calendar;
import lombok.Builder;
import lombok.Value;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.databind.PropertyNamingStrategy;
import com.fasterxml.jackson.databind.annotation.JsonNaming;
import com.fasterxml.jackson.annotation.JsonValue;
public enum JacksonExampleEnum {
OPTION_1("0", "0"), OPTION_2("1", "1");
private String a;
private String b;
JacksonTestEnum(String a, String b) {
this.a = a;
this.b = b;