Klasse ETagWebRequestor
- Alle implementierten Schnittstellen:
WebRequestor
The ETagWebRequestor
caches all GET-requests with an ETag header field in a SoftHashMap
and
uses the ETag on the next request as If-None-Match
header field if the same URL is requested.
Is the response status code 304 (NOT MODIFIED) the old response from cache is used.
Attention: even 304 responses count as request at Facebook and so they count against the throttling limits. Facebook suggests to use them for data that change only frequently
Further information regarding ETag at Facebook can be found here: https://developers.facebook.com/blog/post/627/
Attention 2: If excessively used with a lot of URLs, the SoftHashMap
can lead to a
performance degradation
-
Verschachtelte Klassen - Übersicht
Von Klasse geerbte verschachtelte Klassen/Schnittstellen com.restfb.DefaultWebRequestor
DefaultWebRequestor.HttpMethod
Von Schnittstelle geerbte verschachtelte Klassen/Schnittstellen com.restfb.WebRequestor
WebRequestor.Request, WebRequestor.Response
-
Konstruktorübersicht
-
Methodenübersicht
Modifizierer und TypMethodeBeschreibungprotected void
customizeConnection
(HttpURLConnection connection) Hook method which allows subclasses to easily customize theconnection
s created byDefaultWebRequestor.executeGet(com.restfb.WebRequestor.Request)
andDefaultWebRequestor.executePost(com.restfb.WebRequestor.Request)
- for example, setting a custom read timeout or request header.protected WebRequestor.Response
fetchResponse
(HttpURLConnection httpUrlConnection) boolean
return if cache is used.static void
setMapSupplier
(Supplier<Map<String, com.restfb.ETagWebRequestor.ETagResponse>> mapSupplier) Override the mapSupplier, it needs to be some implementation of theMap
interface.void
setUseCache
(boolean useCache) activate/deactivate the ETag-Cache for the next request.Von Klasse geerbte Methoden com.restfb.DefaultWebRequestor
closeQuietly, closeQuietly, createFormFieldName, executeDelete, executeGet, executePost, fillHeaderAndDebugInfo, getCurrentHeaders, getDebugHeaderInfo, initHeaderAccessToken, isAutocloseBinaryAttachmentStream, openConnection, setAutocloseBinaryAttachmentStream, write
-
Konstruktordetails
-
ETagWebRequestor
public ETagWebRequestor()
-
-
Methodendetails
-
customizeConnection
Beschreibung aus Klasse kopiert:DefaultWebRequestor
Hook method which allows subclasses to easily customize theconnection
s created byDefaultWebRequestor.executeGet(com.restfb.WebRequestor.Request)
andDefaultWebRequestor.executePost(com.restfb.WebRequestor.Request)
- for example, setting a custom read timeout or request header.This implementation is a no-op.
- Setzt außer Kraft:
customizeConnection
in KlasseDefaultWebRequestor
- Parameter:
connection
- The connection to customize.
-
fetchResponse
protected WebRequestor.Response fetchResponse(HttpURLConnection httpUrlConnection) throws IOException - Setzt außer Kraft:
fetchResponse
in KlasseDefaultWebRequestor
- Löst aus:
IOException
-
isUseCache
return if cache is used.- Gibt zurück:
true
if ETag-Cache is used,false
if not
-
setUseCache
activate/deactivate the ETag-Cache for the next request.when deactivated, the ETag-Cache is *not* deleted
- Parameter:
useCache
- flag to dis/enable the cache during runtime
-
setMapSupplier
public static void setMapSupplier(Supplier<Map<String, com.restfb.ETagWebRequestor.ETagResponse>> mapSupplier) Override the mapSupplier, it needs to be some implementation of theMap
interface. You have to set this before theETagWebRequestor
object is created. While building it, the mapSupplier is used- Parameter:
mapSupplier
- the supplier, that returns a new Map,
-