org.baswell.routes
Class SimpleRoutesCache
java.lang.Object
org.baswell.routes.SimpleRoutesCache
- All Implemented Interfaces:
- RoutesCache
public class SimpleRoutesCache
- extends java.lang.Object
- implements RoutesCache
A very simple in memory cache implementation. This class has not been tested (well) so there are likely issues.
- See Also:
RoutesConfiguration.routesCache
|
Constructor Summary |
SimpleRoutesCache(int maxCachedRoutes,
int minCleanMSecs,
boolean parametersUsedInRouting)
|
|
Method Summary |
java.lang.Object |
get(HttpMethod method,
RequestedMediaType requestedMediaType,
RequestPath path,
RequestParameters parameters)
Retrieve the cached route instance or null on a cache miss. |
protected java.lang.String |
getKey(HttpMethod method,
RequestedMediaType requestedMediaType,
RequestPath path,
RequestParameters parameters)
|
void |
put(java.lang.Object routeNode,
HttpMethod method,
RequestedMediaType requestedMediaType,
RequestPath path,
RequestParameters parameters)
Called after a request has been processed by the given routeNode. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
SimpleRoutesCache
public SimpleRoutesCache(int maxCachedRoutes,
int minCleanMSecs,
boolean parametersUsedInRouting)
- Parameters:
maxCachedRoutes - The maximum number of routes to cache in memory.minCleanMSecs - The minimum number of seconds between cache cleans.parametersUsedInRouting - Are parameters used in determining route matches?
get
public java.lang.Object get(HttpMethod method,
RequestedMediaType requestedMediaType,
RequestPath path,
RequestParameters parameters)
- Description copied from interface:
RoutesCache
- Retrieve the cached route instance or
null on a cache miss.
- Specified by:
get in interface RoutesCache
- Parameters:
method - The HTTP method.requestedMediaType - The requested media type.path - The HTTP path.parameters - The HTTP parameters.
- Returns:
- The cached route instance or
null on a cache miss.
put
public void put(java.lang.Object routeNode,
HttpMethod method,
RequestedMediaType requestedMediaType,
RequestPath path,
RequestParameters parameters)
- Description copied from interface:
RoutesCache
- Called after a request has been processed by the given
routeNode. This request should be cached for later retrieval
from get when the HTTP request input parameters match.
- Specified by:
put in interface RoutesCache
- Parameters:
routeNode - The route instance to be retrieved later from get.method - The HTTP method.requestedMediaType - The requested media type.path - The HTTP path.parameters - The HTTP parameters.
getKey
protected java.lang.String getKey(HttpMethod method,
RequestedMediaType requestedMediaType,
RequestPath path,
RequestParameters parameters)