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

org.nervousync.cache.api.CacheClient Maven / Gradle / Ivy

/*
 * Copyright 2022 Nervousync Studio
 * 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.nervousync.cache.api;

public interface CacheClient {

	static final int DEFAULT_EXPIRE_TIME = -1;

	/**
	 * 

Set key-value to cache server, using default expire time

*

使用指定的过期时间设置缓存信息

* * @param key Cache key * 缓存键值 * @param value Cache value * 缓存数据 */ default void set(String key, String value) { this.set(key, value, DEFAULT_EXPIRE_TIME); } /** *

Set key-value to cache server and set expire time

*

使用指定的过期时间设置缓存信息

* * @param key Cache key * 缓存键值 * @param value Cache value * 缓存数据 * @param expiry Expire time * 过期时间 */ void set(String key, String value, int expiry); /** *

Add a new key-value to cache server, using default expire time

*

使用指定的过期时间添加缓存信息

* * @param key Cache key * 缓存键值 * @param value Cache value * 缓存数据 */ default void add(String key, String value) { this.add(key, value, DEFAULT_EXPIRE_TIME); } /** *

Add a new key-value to cache server and set expire time

*

使用指定的过期时间添加缓存信息

* * @param key Cache key * 缓存键值 * @param value Cache value * 缓存数据 * @param expire Expire time * 过期时间 */ void add(String key, String value, int expire); /** *

Replace exists value of given key by given value, using default expire time

*

使用指定的过期时间替换已存在的缓存信息

* * @param key Cache key * 缓存键值 * @param value Cache value * 缓存数据 */ default void replace(String key, String value) { this.replace(key, value, DEFAULT_EXPIRE_TIME); } /** *

Replace exists value of given key by given value and set expire time

*

使用指定的过期时间替换已存在的缓存信息

* * @param key Cache key * 缓存键值 * @param value Cache value * 缓存数据 * @param expire Expire time * 过期时间 */ void replace(String key, String value, int expire); /** *

Set expire time to new given expire value which cache key was given

*

将指定的缓存键值过期时间设置为指定的新值

* * @param key Cache key * 缓存键值 * @param expire New expire time * 新的过期时间 */ void expire(String key, int expire); /** * Operate touch to given keys * @param keys Keys */ void touch(String... keys); /** *

Remove cache key-value from cache server

*

移除指定的缓存键值

* * @param key Cache key * 缓存键值 */ void delete(String key); /** *

Read cache value from cache key which cache key was given

*

读取指定缓存键值对应的缓存数据

* * @param key Cache key * 缓存键值 * @return Cache value or null if cache key was not exists or it was expired * 读取的缓存数据,如果缓存键值不存在或已过期,则返回null */ String get(String key); /** *

Increment data by given cache key and value

* * @param key Cache key * 缓存键值 * @param step Increment step value * 自增步进值 * @return Operate result * 操作结果 */ long incr(String key, long step); /** *

Decrement data by given cache key and value

* * @param key Cache key * 缓存键值 * @param step Decrement step value * 自减步进值 * @return Operate result * 操作结果 */ long decr(String key, long step); void destroy(); }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy