com.fasterxml.jackson.databind.cfg.DefaultCacheProvider Maven / Gradle / Ivy
Show all versions of redisson-all Show documentation
package com.fasterxml.jackson.databind.cfg;
import com.fasterxml.jackson.databind.*;
import com.fasterxml.jackson.databind.deser.DeserializerCache;
import com.fasterxml.jackson.databind.ser.SerializerCache;
import com.fasterxml.jackson.databind.type.TypeFactory;
import com.fasterxml.jackson.databind.util.LRUMap;
import com.fasterxml.jackson.databind.util.LookupCache;
import com.fasterxml.jackson.databind.util.TypeKey;
/**
* The default implementation of {@link CacheProvider}.
* Configuration is builder-based via {@link DefaultCacheProvider.Builder}.
*
* Users can either use this class or create their own {@link CacheProvider} implementation.
*
* @since 2.16
*/
public class DefaultCacheProvider
implements CacheProvider
{
private static final long serialVersionUID = 1L;
private final static DefaultCacheProvider DEFAULT
= new DefaultCacheProvider(DeserializerCache.DEFAULT_MAX_CACHE_SIZE, SerializerCache.DEFAULT_MAX_CACHE_SIZE, TypeFactory.DEFAULT_MAX_CACHE_SIZE);
/**
* Maximum size of the {@link LookupCache} instance constructed by {@link #forDeserializerCache(DeserializationConfig)}.
*
* @see Builder#maxDeserializerCacheSize(int)
*/
protected final int _maxDeserializerCacheSize;
/**
* Maximum size of the {@link LookupCache} instance constructed by {@link #forSerializerCache(SerializationConfig)}
*
* @see Builder#maxSerializerCacheSize(int)
*/
protected final int _maxSerializerCacheSize;
/**
* Maximum size of the {@link LookupCache} instance constructed by {@link #forTypeFactory()}.
*
* @see Builder#maxTypeFactoryCacheSize(int)
*/
protected final int _maxTypeFactoryCacheSize;
/*
/**********************************************************************
/* Life cycle
/**********************************************************************
*/
protected DefaultCacheProvider(int maxDeserializerCacheSize, int maxSerializerCacheSize, int maxTypeFactoryCacheSize)
{
_maxDeserializerCacheSize = maxDeserializerCacheSize;
_maxSerializerCacheSize = maxSerializerCacheSize;
_maxTypeFactoryCacheSize = maxTypeFactoryCacheSize;
}
/*
/**********************************************************************
/* Defaults
/**********************************************************************
*/
/**
* @return Default {@link DefaultCacheProvider} instance using default configuration values.
*/
public static CacheProvider defaultInstance() {
return DEFAULT;
}
/*
/**********************************************************
/* API implementation
/**********************************************************
*/
/**
* Method to provide a {@link LookupCache} instance for constructing {@link DeserializerCache}.
* Implementation should match {@link DeserializerCache#DeserializerCache(int)}.
*
* @return {@link LookupCache} instance for constructing {@link DeserializerCache}.
*/
@Override
public LookupCache> forDeserializerCache(DeserializationConfig config) {
return _buildCache(_maxDeserializerCacheSize);
}
@Override
public LookupCache> forSerializerCache(SerializationConfig config) {
return _buildCache(_maxSerializerCacheSize);
}
@Override
public LookupCache