com.github.lontime.shaded.org.redisson.api.RBucketAsync Maven / Gradle / Ivy
/**
* Copyright (c) 2013-2021 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 com.github.lontime.shaded.org.redisson.api;
import java.time.Duration;
import java.time.Instant;
import java.util.concurrent.TimeUnit;
/**
* Async implementation of object holder. Max size of object is 512MB
*
* @author Nikita Koksharov
*
* @param - the type of object
*/
public interface RBucketAsync extends RExpirableAsync {
/**
* Returns size of object in bytes
*
* @return object size
*/
RFuture sizeAsync();
/**
* Retrieves element stored in the holder.
*
* @return element
*/
RFuture getAsync();
/**
* Retrieves element in the holder and removes it.
*
* @return element
*/
RFuture getAndDeleteAsync();
/**
* Tries to set element atomically into empty holder.
*
* @param value - value to set
* @return {@code true} if successful, or {@code false} if
* element was already set
*/
RFuture trySetAsync(V value);
/**
* Tries to set element atomically into empty holder with defined timeToLive
interval.
*
* @param value - value to set
* @param timeToLive - time to live interval
* @param timeUnit - unit of time to live interval
* @return {@code true} if successful, or {@code false} if
* element was already set
*/
RFuture trySetAsync(V value, long timeToLive, TimeUnit timeUnit);
/**
* Sets value only if it's already exists.
*
* @param value - value to set
* @return {@code true} if successful, or {@code false} if
* element wasn't set
*/
RFuture setIfExistsAsync(V value);
/**
* Sets value only if it's already exists.
*
* @param value - value to set
* @param timeToLive - time to live interval
* @param timeUnit - unit of time to live interval
* @return {@code true} if successful, or {@code false} if
* element wasn't set
*/
RFuture setIfExistsAsync(V value, long timeToLive, TimeUnit timeUnit);
/**
* Atomically sets the value to the given updated value
* only if serialized state of the current value equals
* to serialized state of the expected value.
*
* @param expect the expected value
* @param update the new value
* @return {@code true} if successful; or {@code false} if the actual value
* was not equal to the expected value.
*/
RFuture compareAndSetAsync(V expect, V update);
/**
* Retrieves current element in the holder and replaces it with newValue
.
*
* @param newValue - value to set
* @return previous value
*/
RFuture getAndSetAsync(V newValue);
/**
* Retrieves current element in the holder and replaces it with newValue
with defined timeToLive
interval.
*
* @param value - value to set
* @param timeToLive - time to live interval
* @param timeUnit - unit of time to live interval
* @return previous value
*/
RFuture getAndSetAsync(V value, long timeToLive, TimeUnit timeUnit);
/**
* Retrieves current element in the holder and sets an expiration duration for it.
*
* Requires Redis 6.2.0 and higher.
*
* @param duration of object time to live interval
* @return element
*/
RFuture getAndExpireAsync(Duration duration);
/**
* Retrieves current element in the holder and sets an expiration date for it.
*
* Requires Redis 6.2.0 and higher.
*
* @param time of exact object expiration moment
* @return element
*/
RFuture getAndExpireAsync(Instant time);
/**
* Retrieves current element in the holder and clears expiration date set before.
*
* Requires Redis 6.2.0 and higher.
*
* @return element
*/
RFuture getAndClearExpireAsync();
/**
* Stores element into the holder.
*
* @param value - value to set
* @return void
*/
RFuture setAsync(V value);
/**
* Stores element into the holder with defined timeToLive
interval.
*
* @param value - value to set
* @param timeToLive - time to live interval
* @param timeUnit - unit of time to live interval
* @return void
*/
RFuture setAsync(V value, long timeToLive, TimeUnit timeUnit);
/**
* Set value and keep existing TTL.
*
* Requires Redis 6.0.0 and higher.
*
* @param value - value to set
* @return void
*/
RFuture setAndKeepTTLAsync(V value);
/**
* Adds object event listener
*
* @see com.github.lontime.shaded.org.redisson.api.ExpiredObjectListener
* @see com.github.lontime.shaded.org.redisson.api.DeletedObjectListener
* @see com.github.lontime.shaded.org.redisson.api.listener.SetObjectListener
*
* @param listener - object event listener
* @return listener id
*/
RFuture addListenerAsync(ObjectListener listener);
}