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

org.redisson.api.RMapReactive Maven / Gradle / Ivy

There is a newer version: 0.40.13
Show newest version
/**
 * Copyright 2018 Nikita Koksharov
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.redisson.api;

import java.util.Collection;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;

import org.redisson.api.map.MapLoader;
import org.redisson.api.map.MapWriter;

import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;

/**
 *  map functions
 *
 * @author Nikita Koksharov
 *
 * @param  key
 * @param  value
 */
public interface RMapReactive extends RExpirableReactive {

    /**
     * Loads all map entries to this Redis map using {@link org.redisson.api.map.MapLoader}.
     * 
     * @param replaceExistingValues - true if existed values should be replaced, false otherwise.  
     * @param parallelism - parallelism level, used to increase speed of process execution
     * @return void
     */
    Mono loadAll(boolean replaceExistingValues, int parallelism);
    
    /**
     * Loads map entries using {@link org.redisson.api.map.MapLoader} whose keys are listed in defined keys parameter.
     * 
     * @param keys - map keys
     * @param replaceExistingValues - true if existed values should be replaced, false otherwise.
     * @param parallelism - parallelism level, used to increase speed of process execution
     * @return void
     */
    Mono loadAll(Set keys, boolean replaceExistingValues, int parallelism);

    /**
     * Returns size of value mapped by key in bytes
     * 
     * @param key - map key
     * @return size of value
     */
    Mono valueSize(K key);

    /**
     * Gets a map slice contained the mappings with defined keys
     * by one operation.
     * 

* If map doesn't contain value/values for specified key/keys and {@link MapLoader} is defined * then value/values will be loaded in read-through mode. *

* The returned map is NOT backed by the original map. * * @param keys - map keys * @return Map slice */ Mono> getAll(Set keys); /** * Associates the specified value with the specified key * in batch. *

* If {@link MapWriter} is defined then new map entries are stored in write-through mode. * * @param map mappings to be stored in this map * @return void */ Mono putAll(Map map); Mono addAndGet(K key, Number value); Mono containsValue(Object value); Mono containsKey(Object key); Mono size(); /** * Removes keys from map by one operation in async manner. *

* Works faster than {@link #remove(Object, Object)} but doesn't return * the value associated with key. *

* If {@link MapWriter} is defined then keysare deleted in write-through mode. * * @param keys - map keys * @return the number of keys that were removed from the hash, not including specified but non existing keys */ Mono fastRemove(K ... keys); /** * Associates the specified value with the specified key * in async manner. *

* Works faster than {@link #put(Object, Object)} but not returning * the previous value associated with key *

* If {@link MapWriter} is defined then new map entry is stored in write-through mode. * * @param key - map key * @param value - map value * @return true if key is a new one in the hash and value was set. * false if key already exists in the hash and the value was updated. */ Mono fastPut(K key, V value); /** * Associates the specified value with the specified key * only if there is no any association with specifiedkey. *

* Works faster than {@link #putIfAbsent(Object, Object)} but not returning * the previous value associated with key *

* If {@link MapWriter} is defined then new map entry is stored in write-through mode. * * @param key - map key * @param value - map value * @return true if key is a new one in the hash and value was set. * false if key already exists in the hash and change hasn't been made. */ Mono fastPutIfAbsent(K key, V value); /** * Read all keys at once * * @return keys */ Mono> readAllKeySet(); /** * Read all values at once * * @return values */ Mono> readAllValues(); /** * Read all map entries at once * * @return entries */ Mono>> readAllEntrySet(); /** * Read all map as local instance at once * * @return map */ Mono> readAllMap(); /** * Returns the value to which the specified key is mapped, * or {@code null} if this map contains no mapping for the key. *

* If map doesn't contain value for specified key and {@link MapLoader} is defined * then value will be loaded in read-through mode. * * @param key the key whose associated value is to be returned * @return the value to which the specified key is mapped, or * {@code null} if this map contains no mapping for the key */ Mono get(K key); /** * Associates the specified value with the specified key * in async manner. *

* If {@link MapWriter} is defined then new map entry is stored in write-through mode. * * @param key - map key * @param value - map value * @return previous associated value */ Mono put(K key, V value); /** * Removes key from map and returns associated value in async manner. *

* If {@link MapWriter} is defined then keyis deleted in write-through mode. * * @param key - map key * @return deleted value or null if there wasn't any association */ Mono remove(K key); /** * Replaces previous value with a new value associated with the key. * If there wasn't any association before then method returns null. *

* If {@link MapWriter} is defined then new valueis written in write-through mode. * * @param key - map key * @param value - map value * @return previous associated value * or null if there wasn't any association and change hasn't been made */ Mono replace(K key, V value); /** * Replaces previous oldValue with a newValue associated with the key. * If previous value doesn't exist or equal to oldValue then method returns false. *

* If {@link MapWriter} is defined then newValueis written in write-through mode. * * @param key - map key * @param oldValue - map old value * @param newValue - map new value * @return true if value has been replaced otherwise false. */ Mono replace(K key, V oldValue, V newValue); /** * Removes key from map only if it associated with value. *

* If {@link MapWriter} is defined then keyis deleted in write-through mode. * * @param key - map key * @param value - map value * @return true if map entry has been replaced otherwise false. */ Mono remove(Object key, Object value); /** * Associates the specified value with the specified key * only if there is no any association with specifiedkey. *

* If {@link MapWriter} is defined then new map entry is stored in write-through mode. * * @param key - map key * @param value - map value * @return null if key is a new one in the hash and value was set. * Previous value if key already exists in the hash and change hasn't been made. */ Mono putIfAbsent(K key, V value); /** * Returns iterator over map entries collection. * Map entries are loaded in batch. Batch size is 10. * * @see #readAllEntrySet() * * @return iterator */ Flux> entryIterator(); /** * Returns iterator over map entries collection. * Map entries are loaded in batch. Batch size is defined by count param. * * @see #readAllEntrySet() * * @param count - size of entries batch * @return iterator */ Flux> entryIterator(int count); /** * Returns iterator over map entries collection. * Map entries are loaded in batch. Batch size is 10. * If keyPattern is not null then only entries mapped by matched keys of this pattern are loaded. * * Supported glob-style patterns: *

* h?llo subscribes to hello, hallo and hxllo *

* h*llo subscribes to hllo and heeeello *

* h[ae]llo subscribes to hello and hallo, but not hillo * * @see #readAllEntrySet() * * @param pattern - key pattern * @return iterator */ Flux> entryIterator(String pattern); /** * Returns iterator over map entries collection. * Map entries are loaded in batch. Batch size is defined by count param. * If keyPattern is not null then only entries mapped by matched keys of this pattern are loaded. * * Supported glob-style patterns: *

* h?llo subscribes to hello, hallo and hxllo *

* h*llo subscribes to hllo and heeeello *

* h[ae]llo subscribes to hello and hallo, but not hillo * * @see #readAllEntrySet() * * @param pattern - key pattern * @param count - size of entries batch * @return iterator */ Flux> entryIterator(String pattern, int count); /** * Returns iterator over values collection of this map. * Values are loaded in batch. Batch size is 10. * * @see #readAllValues() * * @return iterator */ Flux valueIterator(); /** * Returns iterator over values collection of this map. * Values are loaded in batch. Batch size is defined by count param. * * @see #readAllValues() * * @param count - size of values batch * @return iterator */ Flux valueIterator(int count); /** * Returns iterator over values collection of this map. * Values are loaded in batch. Batch size is 10. * If keyPattern is not null then only values mapped by matched keys of this pattern are loaded. * * Supported glob-style patterns: *

* h?llo subscribes to hello, hallo and hxllo *

* h*llo subscribes to hllo and heeeello *

* h[ae]llo subscribes to hello and hallo, but not hillo * * @see #readAllValues() * * @param pattern - key pattern * @return iterator */ Flux valueIterator(String pattern); /** * Returns iterator over values collection of this map. * Values are loaded in batch. Batch size is defined by count param. * If keyPattern is not null then only values mapped by matched keys of this pattern are loaded. * * Supported glob-style patterns: *

* h?llo subscribes to hello, hallo and hxllo *

* h*llo subscribes to hllo and heeeello *

* h[ae]llo subscribes to hello and hallo, but not hillo * * @see #readAllValues() * * @param pattern - key pattern * @param count - size of values batch * @return iterator */ Flux valueIterator(String pattern, int count); /** * Returns iterator over key set of this map. * Keys are loaded in batch. Batch size is 10. * * @see #readAllKeySet() * * @return iterator */ Flux keyIterator(); /** * Returns iterator over key set of this map. * Keys are loaded in batch. Batch size is defined by count param. * * @see #readAllKeySet() * * @param count - size of keys batch * @return iterator */ Flux keyIterator(int count); /** * Returns iterator over key set of this map. * If pattern is not null then only keys match this pattern are loaded. * * Supported glob-style patterns: *

* h?llo subscribes to hello, hallo and hxllo *

* h*llo subscribes to hllo and heeeello *

* h[ae]llo subscribes to hello and hallo, but not hillo * * @see #readAllKeySet() * * @param pattern - key pattern * @return iterator */ Flux keyIterator(String pattern); /** * Returns iterator over key set of this map. * If pattern is not null then only keys match this pattern are loaded. * Keys are loaded in batch. Batch size is defined by count param. * * Supported glob-style patterns: *

* h?llo subscribes to hello, hallo and hxllo *

* h*llo subscribes to hllo and heeeello *

* h[ae]llo subscribes to hello and hallo, but not hillo * * @see #readAllKeySet() * * @param pattern - key pattern * @param count - size of keys batch * @return iterator */ Flux keyIterator(String pattern, int count); /** * Returns RPermitExpirableSemaphore instance associated with key * * @param key - map key * @return permitExpirableSemaphore */ RPermitExpirableSemaphoreReactive getPermitExpirableSemaphore(K key); /** * Returns RSemaphore instance associated with key * * @param key - map key * @return semaphore */ RSemaphoreReactive getSemaphore(K key); /** * Returns RLock instance associated with key * * @param key - map key * @return fairLock */ RLockReactive getFairLock(K key); /** * Returns RReadWriteLock instance associated with key * * @param key - map key * @return readWriteLock */ RReadWriteLockReactive getReadWriteLock(K key); /** * Returns RLock instance associated with key * * @param key - map key * @return lock */ RLockReactive getLock(K key); }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy