Class SimpleKeyGenerator
- java.lang.Object
- org.springframework.cache.interceptor.SimpleKeyGenerator
- All Implemented Interfaces:
KeyGenerator
public class SimpleKeyGenerator extends Object implements KeyGenerator
Simple key generator. Returns the parameter itself if a single non-null value is given, otherwise returns aSimpleKey
of the parameters.Unlike
DefaultKeyGenerator
, no collisions will occur with the keys generated by this class. The returnedSimpleKey
object can be safely used with aConcurrentMapCache
, however, might not be suitable for allCache
implementations.- Since:
- 4.0
- Author:
- Phillip Webb, Juergen Hoeller
- See Also:
SimpleKey
,DefaultKeyGenerator
,CachingConfigurer
Constructor Summary
Constructors Constructor Description SimpleKeyGenerator()
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Object
generate(Object target, Method method, Object... params)
Generate a key for the given method and its parameters.static Object
generateKey(Object... params)
Generate a key based on the specified parameters.
Constructor Detail
SimpleKeyGenerator
public SimpleKeyGenerator()
Method Detail
generate
public Object generate(Object target, Method method, Object... params)
Description copied from interface:KeyGenerator
Generate a key for the given method and its parameters.- Specified by:
generate
in interfaceKeyGenerator
- Parameters:
target
- the target instancemethod
- the method being calledparams
- the method parameters (with any var-args expanded)- Returns:
- a generated key
generateKey
public static Object generateKey(Object... params)
Generate a key based on the specified parameters.