org.codeforamerica.open311.internals.caching
Class NoCache

java.lang.Object
  extended by org.codeforamerica.open311.internals.caching.NoCache
All Implemented Interfaces:
Cache

public class NoCache
extends Object
implements Cache

This class is a special implementation of the Cache interface which is useful if you don't want to do caching.

Author:
Santiago MunĂ­n

Nested Class Summary
 
Nested classes/interfaces inherited from interface org.codeforamerica.open311.internals.caching.Cache
Cache.CacheableOperation
 
Constructor Summary
NoCache()
           
 
Method Summary
 void deleteCache()
          Deletes the cache.
 ServiceDefinition retrieveCachedServiceDefinition(String endpointUrl, String serviceCode)
          Looks for a cached service definition.
 ServiceDiscoveryInfo retrieveCachedServiceDiscoveryInfo(City city)
          Looks for the service discovery of a given city in the local cache.
 List<Service> retrieveCachedServiceList(String endpointUrl)
          Looks for a cached list of services.
 ServiceRequest retrieveCachedServiceRequest(String endpointUrl, String serviceRequestId)
          Looks for a cached GET service request response.
 List<ServiceRequest> retrieveCachedServiceRequests(String endpointUrl, GETServiceRequestsFilter filter)
          Looks for a cached GET service requests response.
 String retrieveCitiesInfo()
          Looks for the endpoints-service discovery relationships.
 void saveCitiesInfo(String data)
          Saves the endpoints-service discovery relationships.
 void saveListOfServices(String endpointUrl, List<Service> services)
          Saves a list of Service objects related to an endpoint.
 void saveServiceDefinition(String endpointUrl, String serviceCode, ServiceDefinition serviceDefinition)
          Saves a service definition.
 void saveServiceDiscovery(City city, ServiceDiscoveryInfo serviceDiscovery)
          Saves a object related to a city.
 void saveServiceRequestList(String endpointUrl, GETServiceRequestsFilter filter, List<ServiceRequest> requests)
          Saves a list of service requests.
 void saveSingleServiceRequest(String endpointUrl, String serviceRequestId, ServiceRequest request)
          Saves a service request.
 void setCustomTimeToLive(Cache.CacheableOperation operation, int timeToLiveInHours)
          Set a custom time to live to a given operation.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NoCache

public NoCache()
Method Detail

saveCitiesInfo

public void saveCitiesInfo(String data)
Description copied from interface: Cache
Saves the endpoints-service discovery relationships.

Specified by:
saveCitiesInfo in interface Cache
Parameters:
data - A JSON list.

retrieveCitiesInfo

public String retrieveCitiesInfo()
Description copied from interface: Cache
Looks for the endpoints-service discovery relationships.

Specified by:
retrieveCitiesInfo in interface Cache
Returns:
A JSON list or null if it wasn't found.

saveServiceDiscovery

public void saveServiceDiscovery(City city,
                                 ServiceDiscoveryInfo serviceDiscovery)
Description copied from interface: Cache
Saves a object related to a city.

Specified by:
saveServiceDiscovery in interface Cache
Parameters:
city - City related to the requested service discovery.
serviceDiscovery - The obtained service discovery.

retrieveCachedServiceDiscoveryInfo

public ServiceDiscoveryInfo retrieveCachedServiceDiscoveryInfo(City city)
Description copied from interface: Cache
Looks for the service discovery of a given city in the local cache.

Specified by:
retrieveCachedServiceDiscoveryInfo in interface Cache
Parameters:
city - City of interest.
Returns:
The service discovery of the given city of null if it isn't cached.

saveListOfServices

public void saveListOfServices(String endpointUrl,
                               List<Service> services)
Description copied from interface: Cache
Saves a list of Service objects related to an endpoint.

Specified by:
saveListOfServices in interface Cache
Parameters:
endpointUrl - Url of the endpoint.
services - Obtained services.

retrieveCachedServiceList

public List<Service> retrieveCachedServiceList(String endpointUrl)
Description copied from interface: Cache
Looks for a cached list of services.

Specified by:
retrieveCachedServiceList in interface Cache
Parameters:
endpointUrl - Url of the endpoint.
Returns:
The list of services or null if they aren't cached.

saveServiceDefinition

public void saveServiceDefinition(String endpointUrl,
                                  String serviceCode,
                                  ServiceDefinition serviceDefinition)
Description copied from interface: Cache
Saves a service definition.

Specified by:
saveServiceDefinition in interface Cache
Parameters:
endpointUrl - Url of the endpoint.
serviceCode - Code of the service.
serviceDefinition - Obtained definition from the server.

retrieveCachedServiceDefinition

public ServiceDefinition retrieveCachedServiceDefinition(String endpointUrl,
                                                         String serviceCode)
Description copied from interface: Cache
Looks for a cached service definition.

Specified by:
retrieveCachedServiceDefinition in interface Cache
Parameters:
endpointUrl - Url of the endpoint.
serviceCode - Service code of the desired service.
Returns:
A service definition or null if it isn't cached.

saveServiceRequestList

public void saveServiceRequestList(String endpointUrl,
                                   GETServiceRequestsFilter filter,
                                   List<ServiceRequest> requests)
Description copied from interface: Cache
Saves a list of service requests.

Specified by:
saveServiceRequestList in interface Cache
Parameters:
endpointUrl - Url of the endpoint.
filter - Filter sent to the endpoint.
requests - Obtained list of requests.

retrieveCachedServiceRequests

public List<ServiceRequest> retrieveCachedServiceRequests(String endpointUrl,
                                                          GETServiceRequestsFilter filter)
Description copied from interface: Cache
Looks for a cached GET service requests response.

Specified by:
retrieveCachedServiceRequests in interface Cache
Parameters:
endpointUrl - Url of the endpoint.
filter - The desired filter.
Returns:
A list of ServiceRequest or null if they aren't cached.

saveSingleServiceRequest

public void saveSingleServiceRequest(String endpointUrl,
                                     String serviceRequestId,
                                     ServiceRequest request)
Description copied from interface: Cache
Saves a service request.

Specified by:
saveSingleServiceRequest in interface Cache
Parameters:
endpointUrl - Url of the endpoint.
serviceRequestId - Id of the requested service request.
request - Obtained service request.

retrieveCachedServiceRequest

public ServiceRequest retrieveCachedServiceRequest(String endpointUrl,
                                                   String serviceRequestId)
Description copied from interface: Cache
Looks for a cached GET service request response.

Specified by:
retrieveCachedServiceRequest in interface Cache
Parameters:
endpointUrl - Url of the endpoint.
serviceRequestId - The service request's id.
Returns:
A ServiceRequest or null if it wasn't cached.

deleteCache

public void deleteCache()
Description copied from interface: Cache
Deletes the cache.

Specified by:
deleteCache in interface Cache

setCustomTimeToLive

public void setCustomTimeToLive(Cache.CacheableOperation operation,
                                int timeToLiveInHours)
Description copied from interface: Cache
Set a custom time to live to a given operation.

Specified by:
setCustomTimeToLive in interface Cache
Parameters:
operation - Operation which time to live will be changed.
timeToLiveInHours - New time to live (in hours).


Copyright © 2013 Code for America. All Rights Reserved.