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

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

The newest version!
/*
 * Licensed to the Nervousync Studio (NSYC) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You 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;

/**
 * 

Cache client interface

*

缓存客户端接口

*/ public interface CacheClient { /** * Default cache expire time * 默认缓存有效时间 */ 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(final String key, final 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 expire Expire time * 过期时间 */ void set(final String key, final String value, final int expire); /** *

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

*

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

* * @param key Cache key * 缓存键值 * @param value Cache value * 缓存数据 */ default void add(final String key, final 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(final String key, final String value, final 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(final String key, final 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(final String key, final String value, final 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(final String key, final int expire); /** *

Execute touch operate which cache key was given

*

修改指定缓存键值的最后访问时间

* * @param keys Cache keys array strings * 缓存键值数组 */ void touch(final String... keys); /** *

Remove cache key-value from cache server

*

移除指定的缓存键值

* * @param key Cache key * 缓存键值 */ void delete(final 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(final String key); /** *

Increment data by given cache key and value

*

对给定的缓存键值执行自增操作,增加值为给定的步进值

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

Decrement data by given cache key and value

*

对给定的缓存键值执行自减操作,减少值为给定的步进值

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

Destroy cache client

*

销毁当前缓存客户端

*/ void destroy(); }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy