HTTP PUT and POST methods are used to place data in the cache - the data being the body of the request (the data can be anything you like). It is important that a Content-Type header is set.
A PUT request of the above URL form will place the payload (body) in the given cache, with the given key (the named cache must exist on the server). For example http://someserver/hr/payRoll/3 (in which case "hr" is the cache name, and "payRoll/3" is the key). Any existing data will be replaced, and Time-To-Live and Last-Modified values etc will updated (if applicable).
Exactly the same as PUT, only if a value in a cache/key already exists, it will return a Http CONFLICT status (and the content will not be updated).
- Content-Type: MANDATORY (use media/mime-types for example: "application/json").
If you set the Content-Type to application/x-java-serialized-object, then it will be stored as a Java object
- performAsync: OPTIONAL true/false (if true, this will return immediately, and then replicate data to the cluster on its own. Can help with bulk data inserts/large clusters.)
- timeToLiveSeconds: OPTIONAL number (the number of seconds before this entry will automatically be deleted)
- If no parameter is sent, Infinispan assumes -1 as default value, which means that the entry will not expire as a result of ttl. Passing any negative value will have the same effect.
- maxIdleTimeSeconds: OPTIONAL number (the number of seconds after last usage of this entry when it will automatically be deleted)
- If no parameter is sent, Infinispan assumes -1 as default value, which means that the entry will not expire as a result of idle time. Passing any negative value will have the same effect.
|Passing 0 as parameter for timeToLiveSeconds and/or maxIdleTimeSeconds|
HTTP GET and HEAD are used to retrieve data from entries.
This will return the data found in the given cacheName, under the given key - as the body of the response. A Content-Type header will be supplied which matches what the data was inserted as (other then if it is a Java object, see below). Browsers can use the cache directly of course (eg as a CDN).
An ETag will be returned unique for each entry, as will the Last-Modified header field indicating the state of the data at the given URL. ETags allow browsers (and other clients) to ask for data only in the case where it has changed (to save on bandwidth) - this is standard HTTP and is honoured by Infinispan.
The same as GET, only no content is returned (only the header fields). You will receive the same content that you stored. E.g., if you stored a String, this is what you get back. If you stored some XML or JSON, this is what you will receive. If you stored a binary (base 64 encoded) blob, perhaps a serialized; Java; object - you will need to; deserialize this yourself.
|Prior to Infinispan 4.2|
The behaivour was as follows:
If the data in the grid is a Java object - there are a few options in how it can be returned, which use the HTTP Accept header:
Data can be removed at the cache key/element level, or via a whole cache name using the HTTP delete method.
Removes the given key name from the cache.
Removes ALL the entries in the given cache name (ie everything from that path down). If the operation is successful, it returns 200 code.
|Make it quicker!|
Set the header performAsync to true to return immediately and let the removal happen in the background.