Package org.qi4j.api.cache

Examples of org.qi4j.api.cache.CacheOptions


                    {
                        public void visitMap( MapEntityStore.MapChanger changer )
                                throws IOException
                        {
                            DefaultEntityStoreUnitOfWork uow = (DefaultEntityStoreUnitOfWork) unitOfWork;
                            CacheOptions options = uow.usecase().metaInfo( CacheOptions.class );
                            if( options == null )
                            {
                                options = CacheOptions.ALWAYS;
                            }

                            for( EntityState entityState : state )
                            {
                                JSONEntityState state = (JSONEntityState) entityState;
                                if( state.status().equals( EntityStatus.NEW ) )
                                {
                                    Writer writer = changer.newEntity( state.identity(),
                                            state.entityDescriptor() );
                                    writeEntityState( state, writer, unitOfWork.identity(), unitOfWork.currentTime() );
                                    writer.close();
                                    if( options.cacheOnNew() )
                                    {
                                        cache.put( state.identity().identity(), new CacheState(state.state()) );
                                    }
                                } else if( state.status().equals( EntityStatus.UPDATED ) )
                                {
                                    Writer writer = changer.updateEntity( state.identity(),
                                            state.entityDescriptor() );
                                    writeEntityState( state, writer, unitOfWork.identity(), unitOfWork.currentTime() );
                                    writer.close();
                                    if( options.cacheOnWrite() )
                                    {
                                        cache.put( state.identity().identity(), new CacheState(state.state()) );
                                    }
                                } else if( state.status().equals( EntityStatus.REMOVED ) )
                                {
View Full Code Here


        return null;
    }

    private boolean doCacheOnRead( DefaultEntityStoreUnitOfWork unitOfWork )
    {
        CacheOptions cacheOptions = (unitOfWork).usecase().metaInfo( CacheOptions.class );
        return cacheOptions == null || cacheOptions.cacheOnRead();
    }
View Full Code Here

                        @Override
                        public void visitMap( MapEntityStore.MapChanger changer )
                            throws IOException
                        {
                            DefaultEntityStoreUnitOfWork uow = (DefaultEntityStoreUnitOfWork) unitOfWork;
                            CacheOptions options = uow.usecase().metaInfo( CacheOptions.class );
                            if( options == null )
                            {
                                options = CacheOptions.ALWAYS;
                            }

                            for( EntityState entityState : state )
                            {
                                JSONEntityState state = (JSONEntityState) entityState;
                                if( state.status().equals( EntityStatus.NEW ) )
                                {
                                    try( Writer writer = changer.newEntity( state.identity(), state.entityDescriptor() ) )
                                    {
                                        writeEntityState( state, writer, unitOfWork.identity(), unitOfWork.currentTime() );
                                    }
                                    if( options.cacheOnNew() )
                                    {
                                        cache.put( state.identity().identity(), new CacheState( state.state() ) );
                                    }
                                }
                                else if( state.status().equals( EntityStatus.UPDATED ) )
                                {
                                    try( Writer writer = changer.updateEntity( state.identity(), state.entityDescriptor() ) )
                                    {
                                        writeEntityState( state, writer, unitOfWork.identity(), unitOfWork.currentTime() );
                                    }
                                    if( options.cacheOnWrite() )
                                    {
                                        cache.put( state.identity().identity(), new CacheState( state.state() ) );
                                    }
                                }
                                else if( state.status().equals( EntityStatus.REMOVED ) )
View Full Code Here

        return null;
    }

    private boolean doCacheOnRead( DefaultEntityStoreUnitOfWork unitOfWork )
    {
        CacheOptions cacheOptions = unitOfWork.usecase().metaInfo( CacheOptions.class );
        return cacheOptions == null || cacheOptions.cacheOnRead();
    }
View Full Code Here

TOP

Related Classes of org.qi4j.api.cache.CacheOptions

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.