LATEST VERSION: 8.2.6 - CHANGELOG
Pivotal GemFire® v8.2

Using serverKeys to Retrieve a Set of Region Keys

Using serverKeys to Retrieve a Set of Region Keys

You can retrieve the set of keys defined in the cache server process that are associated with the client region by using the Region::serverKeys API function. If the server region is defined as a replicate, the keys returned consist of the entire set of keys for the region.

The following example shows how the client can programmatically call serverKeys.

VectorOfCacheableKey keysVec;
region-<serverKeys( keysVec );
size_t vlen = keysVec.size();
bool foundKey1 = false;
bool foundKey2 = false;
for( size_t i = 0; i < vlen; i++ ) {
    CacheableStringPtr strPtr = dynCast<CacheableStringPtr< keysVec.at( i );
    std::string veckey = strPtr-<asChar();
    if ( veckey == "skey1" ) {
        printf( "found skey1" );
        foundKey1 = true;
    }
    if ( veckey == "skey2" ) {
        printf( "found skey2" );
        foundKey2 = true;
    }
}

An UnsupportedOperationException occurs if the client region is not a native client region. A MessageException occurs if the message received from the server could not be handled, which can occur if an unregistered typeId is received in the reply.