Store, Replace, or Remove Value

post

/ccs/{cacheName}/{key}

Issues one of the following: putIfAbsent, replace, removeValue, or replaceValue.

Request

Supported Media Types
  • application/octet-stream
Path Parameters
cacheName
Type: string
Required: true
Name of cache
key
Type: string
Required: true
Key for the key/value pair to be put, replaced, or removed
Query Parameters
returnOld
Type: boolean
Specifies whether the old value should be returned. Not applicable for replaceValue.
ttl
Type: integer (int64)
Time to live of entry in milliseconds
Header Parameters
X-Method
Type: string
Required: true
Method to invoke - "putIfAbsent", "replace", "removeValue", or "replaceValue"
Body Parameter
Value to be associated with the key. If the method is replaceValue, then the value is of type MultiValue. A MultiValue is a byte array that encodes an arbitrary number of serialized objects. The first 4 bytes are an encoded unsigned int32 (hi byte first) that gives the number of elements in the MultiValue. Each element consists of an encoded unsigned int32, followed by the serialized byte stream of the data item itself.
Root Schema : /paths/~1{cacheName}~1{key}/post/parameters/5/schema
Type: string (binary)

Response

200 Response
Successful response
Body
Root Schema : value
Type: string (binary)
Title: value
Sent if returnOld = true; not applicable for replaceValue
204 Response
Sent if returnOld = false (or missing) or if returnOld = true and no old value exists
404 Response
Specified method not found
409 Response
Conflict error, returned if putIfAbsent requested and old value exists

Examples

The following example shows how to store a value in an Oracle Application Cloud Service cache by submitting a POST request on the REST resource using Java code. For the full application, see Sample Application.

Response postResponse = target
        .path(CACHE_NAME + "/" + testKey)
        .request(MediaType.APPLICATION_OCTET_STREAM)
        .header("X-Method", "putIfAbsent")
        .post(Entity.entity(testValue, MediaType.APPLICATION_OCTET_STREAM));

If the cache referenced by CACHE_NAME doesn’t exist, it is created automatically.

Example of Response Header

The following shows an example of the response header. The 204 code returned indicates that the key/value pair was successfully added. Had the request failed because the key was already in the cache, the HTTP response code would have been 409 (Conflict).

HTTP/1.1 204 No Content 
Date: Wed, 04 Jan 2017 16:41:28 GMT