Accessing Second-Level Cache via Cache interface

An object representation for the second-level cache can be obtained via following method of EntityManagerFactory:

Cache getCache();

The returned value is an instance of Cache interface which has following methods:

package javax.persistence;
...........
public interface Cache {
public boolean contains(Class cls, Object primaryKey);//returns true if the specified entity is in the cache
public void evict(Class cls, Object primaryKey);//removes the specified entity from the cache
public void evict(Class cls);//removes all entities of the specified type from the cache
public void evictAll();//clear the cache
public <T> T unwrap(Class<T> cls);
}

The method unwrap() can be used to obtain the provider specified API to access/manipulate the cache, e.g. the instance of org.hibernate.cache.spi.RegionFactory can be obtained in case of Hibernate.