Codota Logo
Cache
Code IndexAdd Codota 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)

  • Add the Codota plugin to your IDE and get smart completions
private void myMethod () {
StringBuilder s =
  • Codota Iconnew StringBuilder()
  • Codota Iconnew StringBuilder(32)
  • Codota IconString str;new StringBuilder(str)
  • Smart code suggestions by Codota
}
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

  • Making http requests using okhttp
  • getSharedPreferences (Context)
  • compareTo (BigDecimal)
    Compares this BigDecimal with the specified BigDecimal. Two BigDecimal objects that are equal in val
  • addToBackStack (FragmentTransaction)
  • Color (java.awt)
    The Color class is used encapsulate colors in the default sRGB color space or colors in arbitrary co
  • Kernel (java.awt.image)
  • FileReader (java.io)
    A specialized Reader that reads from a file in the file system. All read requests made by calling me
  • Thread (java.lang)
    A thread is a thread of execution in a program. The Java Virtual Machine allows an application to ha
  • DecimalFormat (java.text)
    DecimalFormat is a concrete subclass ofNumberFormat that formats decimal numbers. It has a variety o
  • HttpServlet (javax.servlet.http)
    Provides an abstract class to be subclassed to create an HTTP servlet suitable for a Web site. A sub
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now