이 콘텐츠는 선택한 언어로 제공되지 않습니다.
6.4.2. Adding and Replacing a Key Value
JBoss Data Grid offers a thread-safe data structure.
The following procedure is an example that defines what each line entered into the
DefaultCacheQuickstart.java
file does:
Procedure 6.3. Adding and Replacing a Key Value
- Add an entry with
key
as the key value.cache.put("key", "value");
cache.put("key", "value");
Copy to Clipboard Copied! Toggle word wrap Toggle overflow - Check if the key value is missing. If the value is not found, replace the absent value with
key
. If the value is found, no change occurs.cache.putIfAbsent("key", "newValue");
cache.putIfAbsent("key", "newValue");
Copy to Clipboard Copied! Toggle word wrap Toggle overflow