congrats Icon
New! Announcing Tabnine Chat Beta
Learn More
Tabnine Logo
CachePool
Code IndexAdd Tabnine to your IDE (free)

How to use
CachePool
in
org.apache.polygene.spi.cache

Best Java code snippets using org.apache.polygene.spi.cache.CachePool (Showing top 14 results out of 315)

origin: org.apache.polygene.core/org.apache.polygene.core.testsupport

@Test
public void givenLoooongCacheNameWhenFetchingCacheExpectOk()
{
  Random random = new Random();
  StringBuilder longName = new StringBuilder();
  for( int i = 0; i < 10000; i++ )
  {
    longName.append( (char) ( random.nextInt( 26 ) + 65 ) );
  }
  cache = cachePool.fetchCache( longName.toString(), String.class );
}
origin: org.apache.polygene.core/org.apache.polygene.core.spi

@Override
public void tearDownJSONMapES()
  throws Exception
{
  if( caching != null )
  {
    caching.returnCache( cache );
    cache = null;
  }
}
origin: apache/attic-polygene-java

  @Test
  public void givenCacheWithValueWhenDroppingReferenceAndRequestNewCacheAndItsValueExpectItToBeGone()
  {
    cache.put( "Habba", "Zout" );
    assertEquals( "Zout", cache.get( "Habba" ) );
    cachePool.returnCache( cache );
    cache = cachePool.fetchCache( "1", String.class );
    assertNull( "Value not missing", cache.get( "Habba" ) );
  }
}
origin: org.apache.polygene.core/org.apache.polygene.core.testsupport

  @Test
  public void givenCacheWithValueWhenDroppingReferenceAndRequestNewCacheAndItsValueExpectItToBeGone()
  {
    cache.put( "Habba", "Zout" );
    assertEquals( "Zout", cache.get( "Habba" ) );
    cachePool.returnCache( cache );
    cache = cachePool.fetchCache( "1", String.class );
    assertNull( "Value not missing", cache.get( "Habba" ) );
  }
}
origin: apache/attic-polygene-java

@Test
public void givenLoooongCacheNameWhenFetchingCacheExpectOk()
{
  Random random = new Random();
  StringBuilder longName = new StringBuilder();
  for( int i = 0; i < 10000; i++ )
  {
    longName.append( (char) ( random.nextInt( 26 ) + 65 ) );
  }
  cache = cachePool.fetchCache( longName.toString(), String.class );
}
origin: apache/attic-polygene-java

@Override
public void tearDownJSONMapES()
  throws Exception
{
  if( caching != null )
  {
    caching.returnCache( cache );
    cache = null;
  }
}
origin: org.apache.polygene.core/org.apache.polygene.core.spi

@Override
public void setUpJSONMapES()
  throws Exception
{
  uuid = descriptor.identity() + "-" + UUID.randomUUID().toString();
  if( caching != null )
  {
    cache = caching.fetchCache( uuid, CacheState.class );
  }
  else
  {
    cache = new NullCache<>();
  }
}
origin: apache/attic-polygene-java

@Override
public void setUpJSONMapES()
  throws Exception
{
  uuid = descriptor.identity() + "-" + UUID.randomUUID().toString();
  if( caching != null )
  {
    cache = caching.fetchCache( uuid, CacheState.class );
  }
  else
  {
    cache = new NullCache<>();
  }
}
origin: org.apache.polygene.core/org.apache.polygene.core.testsupport

@Test
public void givenInvalidCacheNameWhenFetchingCacheExpectIllegalArgumentException()
{
  try
  {
    cache = cachePool.fetchCache( "", String.class );
    fail( "Expected " + IllegalArgumentException.class.getSimpleName() );
  }
  catch( IllegalArgumentException e )
  {
    // expected
  }
}
origin: apache/attic-polygene-java

@Test
public void givenInvalidCacheNameWhenFetchingCacheExpectIllegalArgumentException()
{
  try
  {
    cache = cachePool.fetchCache( "", String.class );
    fail( "Expected " + IllegalArgumentException.class.getSimpleName() );
  }
  catch( IllegalArgumentException e )
  {
    // expected
  }
}
origin: org.apache.polygene.core/org.apache.polygene.core.testsupport

@Override
public void setUp()
  throws Exception
{
  super.setUp();
  cachePool = module.instance().findService( CachePool.class ).get();
  cache = cachePool.fetchCache( "1", String.class );
}
origin: apache/attic-polygene-java

@Override
public void setUp()
  throws Exception
{
  super.setUp();
  cachePool = module.instance().findService( CachePool.class ).get();
  cache = cachePool.fetchCache( "1", String.class );
}
origin: org.apache.polygene.core/org.apache.polygene.core.testsupport

@Test
public void givenNullKeyWhenFetchingCacheExpectConstraintViolationException()
{
  try
  {
    cache = cachePool.fetchCache( null, String.class );
    fail( "Expected " + ConstraintViolationException.class.getSimpleName() );
  }
  catch( ConstraintViolationException e )
  {
    // expected
    Collection<ValueConstraintViolation> violations = e.constraintViolations();
    assertEquals( 1, violations.size() );
    ValueConstraintViolation violation = violations.iterator().next();
    assertEquals( "not optional", violation.constraint().toString() );
    assertThat( violation.name(), anyOf(equalTo("cacheId"), equalTo( "arg0" )) );  // depends on whether -parameters was given at compile time.
  }
}
origin: apache/attic-polygene-java

@Test
public void givenNullKeyWhenFetchingCacheExpectConstraintViolationException()
{
  try
  {
    cache = cachePool.fetchCache( null, String.class );
    fail( "Expected " + ConstraintViolationException.class.getSimpleName() );
  }
  catch( ConstraintViolationException e )
  {
    // expected
    Collection<ValueConstraintViolation> violations = e.constraintViolations();
    assertEquals( 1, violations.size() );
    ValueConstraintViolation violation = violations.iterator().next();
    assertEquals( "not optional", violation.constraint().toString() );
    assertThat( violation.name(), anyOf(equalTo("cacheId"), equalTo( "arg0" )) );  // depends on whether -parameters was given at compile time.
  }
}
org.apache.polygene.spi.cacheCachePool

Javadoc

A CachePool is a service that manages the Persistence Caches.

The CachePool is typically implemented as a Polygene Extension, and is an optional extension in the persistence subsystem of Polygene. If a Cache Extension is not provided, caching will be turned off. However, since caching operate on EntityStore level, and is an optional component at that, just because you have defined a Cache Extension does not necessary mean that your system will use it. Check the EntityStore implementations for details if they are Cache enabled. Most EntityStore implementations has this enabled, often via the MapEntityStore and JSONMapEntityStore SPI.

NOTE: Make sure that there is a match between the fetchCache and returnCache methods, to ensure no memory leakage occur. Also remember that if the reference count reaches zero, the CachePool will destroy the Cache as soon as possible and a new fetchCache will return an empty one.

Most used methods

  • fetchCache
    Fetches a cache from the pool. If the cache does not exist already, then a new Cache should be creat
  • returnCache
    Returns the cache back to the pool. The reference count for the cache must then be decreased and if

Popular in Java

  • Reactive rest calls using spring rest template
  • runOnUiThread (Activity)
  • setRequestProperty (URLConnection)
  • getSupportFragmentManager (FragmentActivity)
  • Container (java.awt)
    A generic Abstract Window Toolkit(AWT) container object is a component that can contain other AWT co
  • URL (java.net)
    A Uniform Resource Locator that identifies the location of an Internet resource as specified by RFC
  • MessageDigest (java.security)
    Uses a one-way hash function to turn an arbitrary number of bytes into a fixed-length byte sequence.
  • Date (java.sql)
    A class which can consume and produce dates in SQL Date format. Dates are represented in SQL as yyyy
  • Properties (java.util)
    A Properties object is a Hashtable where the keys and values must be Strings. Each property can have
  • DataSource (javax.sql)
    An interface for the creation of Connection objects which represent a connection to a database. This
  • Top plugins for WebStorm
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now