congrats Icon
New! Tabnine Pro 14-day free trial
Start a free trial
Tabnine Logo
Cache
Code IndexAdd Tabnine to your IDE (free)

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

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

origin: apache/attic-polygene-java

@Test
public void givenCacheWithAValueWhenReplacingValueExpectNewValue()
{
  cache.put( "Habba", "Zout" );
  assertEquals( "Zout", cache.get( "Habba" ) );
  cache.put( "Habba", "Zout2" );
  assertEquals( "Zout2", cache.get( "Habba" ) );
}
origin: apache/attic-polygene-java

@Test
public void givenEmptyCacheWhenFetchingValueExpectNull()
{
  assertNull( cache.get( "1" ) );
}
origin: org.apache.polygene.core/org.apache.polygene.core.spi

  cache.put( state.entityReference().identity().toString(),
        new CacheState( state.state().toString() ) );
  cache.put( state.entityReference().identity().toString(),
        new CacheState( state.state().toString() ) );
cache.remove( state.entityReference().identity().toString() );
origin: apache/attic-polygene-java

cache.put( reference.identity().toString(), new CacheState( loadedState.state().toString() ) );
origin: org.apache.polygene.core/org.apache.polygene.core.testsupport

@Test
public void givenEmptyCacheWhenFetchingValueExpectNull()
{
  assertNull( cache.get( "1" ) );
}
origin: apache/attic-polygene-java

  cache.put( state.entityReference().identity().toString(),
        new CacheState( state.state().toString() ) );
  cache.put( state.entityReference().identity().toString(),
        new CacheState( state.state().toString() ) );
cache.remove( state.entityReference().identity().toString() );
origin: org.apache.polygene.core/org.apache.polygene.core.spi

cache.put( reference.identity().toString(), new CacheState( loadedState.state().toString() ) );
origin: org.apache.polygene.core/org.apache.polygene.core.testsupport

@Test
public void givenCacheWithAValueWhenReplacingValueExpectNewValue()
{
  cache.put( "Habba", "Zout" );
  assertEquals( "Zout", cache.get( "Habba" ) );
  cache.put( "Habba", "Zout2" );
  assertEquals( "Zout2", cache.get( "Habba" ) );
}
origin: apache/attic-polygene-java

private EntityState fetchCachedState( EntityReference reference, ModuleDescriptor module, Instant currentTime )
{
  CacheState cacheState = cache.get( reference.identity().toString() );
  if( cacheState != null )
  {
    JsonObject state = jsonFactories.readerFactory().createReader( new StringReader( cacheState.string ) )
                    .readObject();
    try
    {
      String type = state.getString( JSONKeys.TYPE );
      EntityDescriptor entityDescriptor = module.entityDescriptor( type );
      String version = state.getString( JSONKeys.VERSION );
      Instant modified = Instant.ofEpochMilli( state.getJsonNumber( JSONKeys.MODIFIED ).longValueExact() );
      return new JSONEntityState( entityDescriptor.module(), serialization, jsonFactories,
                    version, modified,
                    reference,
                    EntityStatus.LOADED, entityDescriptor,
                    state );
    }
    catch( Exception e )
    {
      // Should not be able to happen, unless internal error in the cache system.
      throw new EntityStoreException( e );
    }
  }
  return null;
}
origin: org.apache.polygene.core/org.apache.polygene.core.testsupport

@Test
public void givenCacheWithAValueWhenRequestingThatValueExpectItBack()
{
  cache.put( "Habba", "Zout" );
  assertEquals( "Zout", cache.get( "Habba" ) );
}
origin: org.apache.polygene.core/org.apache.polygene.core.spi

private EntityState fetchCachedState( EntityReference reference, ModuleDescriptor module, Instant currentTime )
{
  CacheState cacheState = cache.get( reference.identity().toString() );
  if( cacheState != null )
  {
    JsonObject state = jsonFactories.readerFactory().createReader( new StringReader( cacheState.string ) )
                    .readObject();
    try
    {
      String type = state.getString( JSONKeys.TYPE );
      EntityDescriptor entityDescriptor = module.entityDescriptor( type );
      String version = state.getString( JSONKeys.VERSION );
      Instant modified = Instant.ofEpochMilli( state.getJsonNumber( JSONKeys.MODIFIED ).longValueExact() );
      return new JSONEntityState( entityDescriptor.module(), serialization, jsonFactories,
                    version, modified,
                    reference,
                    EntityStatus.LOADED, entityDescriptor,
                    state );
    }
    catch( Exception e )
    {
      // Should not be able to happen, unless internal error in the cache system.
      throw new EntityStoreException( e );
    }
  }
  return null;
}
origin: apache/attic-polygene-java

@Test
public void givenCacheWithAValueWhenRequestingThatValueExpectItBack()
{
  cache.put( "Habba", "Zout" );
  assertEquals( "Zout", cache.get( "Habba" ) );
}
origin: org.apache.polygene.core/org.apache.polygene.core.spi

@Override
public synchronized String versionOf( EntityStoreUnitOfWork uow, EntityReference reference )
{
  CacheState cacheState = cache.get( reference.identity().toString() );
  if( cacheState != null )
  {
    return jsonFactories.readerFactory().createReader( new StringReader( cacheState.string ) ).readObject()
              .getString( JSONKeys.VERSION );
  }
  // Get state
  try( JsonReader reader = jsonFactories.readerFactory().createReader( mapEntityStore.get( reference ) ) )
  {
    return reader.readObject().getString( JSONKeys.VERSION );
  }
  catch( EntityStoreException ex )
  {
    throw ex;
  }
  catch( Exception ex )
  {
    throw new EntityStoreException( ex );
  }
}
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

@Override
public synchronized String versionOf( EntityStoreUnitOfWork uow, EntityReference reference )
{
  CacheState cacheState = cache.get( reference.identity().toString() );
  if( cacheState != null )
  {
    return jsonFactories.readerFactory().createReader( new StringReader( cacheState.string ) ).readObject()
              .getString( JSONKeys.VERSION );
  }
  // Get state
  try( JsonReader reader = jsonFactories.readerFactory().createReader( mapEntityStore.get( reference ) ) )
  {
    return reader.readObject().getString( JSONKeys.VERSION );
  }
  catch( EntityStoreException ex )
  {
    throw ex;
  }
  catch( Exception ex )
  {
    throw new EntityStoreException( ex );
  }
}
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" ) );
  }
}
org.apache.polygene.spi.cacheCache

Javadoc

Interface to interact with Cache implementations. The Cache interface has the simple put/get/remove method to make implementations very easy and straight forward. The key is always a String, since it is intended to be used for the EntityComposite's reference, and not totally generic.

Most used methods

  • get
  • put
  • remove

Popular in Java

  • Reactive rest calls using spring rest template
  • putExtra (Intent)
  • scheduleAtFixedRate (Timer)
  • runOnUiThread (Activity)
  • URL (java.net)
    A Uniform Resource Locator that identifies the location of an Internet resource as specified by RFC
  • Permission (java.security)
    Legacy security code; do not use.
  • HashSet (java.util)
    HashSet is an implementation of a Set. All optional operations (adding and removing) are supported.
  • Queue (java.util)
    A collection designed for holding elements prior to processing. Besides basic java.util.Collection o
  • DateTimeFormat (org.joda.time.format)
    Factory that creates instances of DateTimeFormatter from patterns and styles. Datetime formatting i
  • Reflections (org.reflections)
    Reflections one-stop-shop objectReflections scans your classpath, indexes the metadata, allows you t
  • 21 Best Atom Packages for 2021
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

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