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

cn.hutool.cache.impl.NoCache Maven / Gradle / Ivy

Go to download

Hutool是一个小而全的Java工具类库,通过静态方法封装,降低相关API的学习成本,提高工作效率,使Java拥有函数式语言般的优雅,让Java语言也可以“甜甜的”。

There is a newer version: 5.8.34
Show newest version
package cn.hutool.cache.impl;

import cn.hutool.cache.Cache;
import cn.hutool.core.exceptions.ExceptionUtil;
import cn.hutool.core.lang.func.Func0;

import java.util.Iterator;

/**
 * 无缓存实现,用于快速关闭缓存
 *
 * @param  键类型
 * @param  值类型
 * @author Looly,jodd
 */
public class NoCache implements Cache {
	private static final long serialVersionUID = 1L;

	@Override
	public int capacity() {
		return 0;
	}

	@Override
	public long timeout() {
		return 0;
	}

	@Override
	public void put(K key, V object) {
		// 跳过
	}

	@Override
	public void put(K key, V object, long timeout) {
		// 跳过
	}

	@Override
	public boolean containsKey(K key) {
		return false;
	}

	@Override
	public V get(K key) {
		return null;
	}

	@Override
	public V get(K key, boolean isUpdateLastAccess) {
		return null;
	}

	@Override
	public V get(K key, Func0 supplier) {
		return get(key, true, supplier);
	}

	@Override
	public V get(K key, boolean isUpdateLastAccess, Func0 supplier) {
		return get(key, isUpdateLastAccess, 0, supplier);
	}

	@Override
	public V get(K key, boolean isUpdateLastAccess, long timeout, Func0 supplier) {
		try {
			return (null == supplier) ? null : supplier.call();
		} catch (Exception e) {
			throw ExceptionUtil.wrapRuntime(e);
		}
	}

	@Override
	public Iterator iterator() {
		return new Iterator() {
			@Override
			public boolean hasNext() {
				return false;
			}

			@Override
			public V next() {
				return null;
			}
		};
	}

	@Override
	public Iterator> cacheObjIterator() {
		return null;
	}

	@Override
	public int prune() {
		return 0;
	}

	@Override
	public boolean isFull() {
		return false;
	}

	@Override
	public void remove(K key) {
		// 跳过
	}

	@Override
	public void clear() {
		// 跳过
	}

	@Override
	public int size() {
		return 0;
	}

	@Override
	public boolean isEmpty() {
		return false;
	}

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy