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

io.vertx.up.uca.cache.Rapid Maven / Gradle / Ivy

package io.vertx.up.uca.cache;

import io.vertx.core.Future;
import io.vertx.core.json.JsonArray;
import io.vertx.ext.auth.User;
import io.vertx.up.exception.web._501NotSupportException;
import io.vertx.up.fn.Fn;

import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import java.util.function.Function;
import java.util.function.Supplier;

/**
 * @author Lang
 */
@SuppressWarnings("all")
public interface Rapid {
    /*
     * Pool:
     *    k = t
     */
    static  Rapid t(final String key) {
        return t(key, -1);
    }

    static  Rapid t(final String key, final int ttl) {
        return Fn.poolThread(P.CACHED_THREAD, () -> new RapidT(key, ttl),
            RapidT.class.getName() + key + ttl);
    }

    /*
     * Pool:
     *    k1 = t1
     *    k2 = t2
     */
    static Rapid, ConcurrentMap> map(final String key) {
        return map(key, -1);
    }

    static Rapid, ConcurrentMap> map(final String key, final int ttl) {
        return Fn.poolThread(P.CACHED_THREAD, () -> new RapidDict(key, ttl),
            RapidDict.class.getName() + key + ttl);
    }

    /*
     * Pool:
     *    habitus = ...
     */
    static  Rapid user(final User user, final String rootKey) {
        return Fn.poolThread(P.CACHED_THREAD, () -> new RapidUser(user, rootKey),
            RapidUser.class.getName() + String.valueOf(user.hashCode()) + rootKey);
    }

    static  Rapid user(final User user) {
        return user(user, null);
    }

    default Future cached(final K key, final Supplier> executor) {
        throw new _501NotSupportException(getClass());
    }

    default Future cached(final K key, final Function> executor) {
        throw new _501NotSupportException(getClass());
    }

    Future write(K key, V value);

    Future clear(K key);

    Future read(K key);
}

@SuppressWarnings("all")
interface P {
    ConcurrentMap CACHED_THREAD = new ConcurrentHashMap<>();
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy