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

com.turbospaces.ebean.LocalEbeanCache Maven / Gradle / Ivy

There is a newer version: 2.0.33
Show newest version
package com.turbospaces.ebean;

import java.util.Objects;

import com.turbospaces.cache.BlockhoundCacheWrapper;
import com.turbospaces.cfg.ApplicationProperties;

import io.ebean.cache.ServerCacheConfig;
import io.ebean.config.CurrentTenantProvider;

public class LocalEbeanCache extends AbstractEbeanCache {
    private final BroadcastChannel dispatcher;

    public LocalEbeanCache(
            ApplicationProperties props,
            String cacheKey,
            BlockhoundCacheWrapper cache,
            CurrentTenantProvider tenantProvider,
            ServerCacheConfig config,
            BroadcastChannel dispatcher) {
        super(props, cacheKey, cache, tenantProvider, config);
        this.dispatcher = Objects.requireNonNull(dispatcher);
    }
    @Override
    public void put(Object id, Object obj) {
        String key = key(id);
        super.put(id, obj);
        dispatcher.broadcastRemoveAsync(cacheKey(), key);
    }
    @Override
    public void remove(Object id) {
        String key = key(id);
        super.remove(id);
        dispatcher.broadcastRemoveAsync(cacheKey(), key);
    }
    @Override
    public void clear() {
        super.clear();
        dispatcher.broadcastClearAllAsync();
    }
    @Override
    public void onRemove(byte[] data) {
        super.onRemove(data);
    }
    @Override
    public int onClear() {
        return super.onClear();
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy