| --- |
| title: Accessing an Entry |
| --- |
| |
| <!-- |
| Licensed to the Apache Software Foundation (ASF) under one or more |
| contributor license agreements. See the NOTICE file distributed with |
| this work for additional information regarding copyright ownership. |
| The ASF licenses this file to You under the Apache License, Version 2.0 |
| (the "License"); you may not use this file except in compliance with |
| the License. You may obtain a copy of the License at |
| |
| http://www.apache.org/licenses/LICENSE-2.0 |
| |
| Unless required by applicable law or agreed to in writing, software |
| distributed under the License is distributed on an "AS IS" BASIS, |
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| See the License for the specific language governing permissions and |
| limitations under the License. |
| --> |
| |
| The `Region::get` method returns the value associated with the specified key, and passes the callback argument to any cache loaders or cache writers that are invoked in the operation. |
| |
| If the value is not present locally, it is requested from the cache server. If the cache server request is unsuccessful, a local cache loader is invoked. |
| |
| The entry value is either retrieved from the local cache or fetched by the region’s locally defined cache loader. |
| |
| In the following example, the program uses the API to do a get for each entry that was put into the cache: |
| |
| ``` pre |
| for ( int32_t i=0; i< 100; i++) { |
| CacheableInt32Ptr res = dynCast<CacheableInt32Ptr>(regionPtr->get(i)); |
| } |
| ``` |
| |
| ## <a id="concept_2B85EC4AB9FA446998147A1539D818CC__section_80F9A9E8F8514A9FBA19106C2473B370" class="no-quick-link"></a>Bulk Get Operations Using getAll |
| |
| You can use the `Region::getAll` method to get values for an array of keys from the local cache or server. If the value for a key is not present locally, then it is requested from the server. |
| |
| **Note:** |
| The value returned is not copied, so multi-threaded applications should not modify the value directly, but should instead use the update methods. |
| |
| The `getAll` method also supports providing a callback argument to any cache loaders or cache writers that are invoked in the operation. |
| |
| |