I don't know quiet enough about how view changes are ordered in infinispan.  But does this needs a CAS also?  I would think only a single call to this method would be done at a time, since this listener is not asynchronous.  In that case a simple set could be used here.

On second thought can a view change occur while you are still starting a cache?  If so then this should maybe do a greater than comparison in case if multiple updates occur at a time.  The viewId is the most significant and currently viewId IIRC is just an incrementing int so you would always want to make sure to only do the update if the new versionPrefix is greater than the current one.  This would need a looping CAS though until either the versionPrefix is lower than the current versionPrefix or the update happened.