polygene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Kent SĂžlvsten <kent.soelvs...@gmail.com>
Subject Re: cache mechanism?
Date Thu, 28 Apr 2016 06:43:25 GMT

The cache is wrapping the EntityStore (in your case the Postgres access)
- if you happen to be familiar to eg. Hibernate, it is similar to a
Hibernate level 2 cache.

This means:

If you create a new entity, the entity will  be created at the cache at
uow.complete() - immediately after writing to postgres.
If you load an existing entity (by id) the cache is checked before
reading from Postgres.
Updating that entity is similar to creation: the cache will be updated
at uow.complete() - nothing happens when the entity becomes "dirty".

Querying is a bit more complex:
When you query for entities, under the hood the query will be performed
against an indexer returning references (id's) for entities.
These references are converted to full entities using either the cache
or postgres.

So the short story: The cache should contain the same state as your
Postgres entitystore.

Another thing is that in you configuration, the EntityStore should have
access to the cache - otherwise the cache will simply be silently
ignored by the persistence mechanism.


Den 28-04-2016 kl. 07:21 skrev zhuangmz08:
> Hi, 
> I would like to assembling the following layers (from up to bottm) [Domain Layer] [Cache
Layer (memcached)] [Persist Layer(entity store / index query)] [Config Layer].
> I can assemble this layers correctly. I can use (domainModule.newUnitOfWork) to write
and query data. I can find the entities stored in Postgres.
> However, I'm confused about caching mechanism here?
> When did the system put entity into cache? When newEntityInstance and uow.complete? When
newQurey.find and uow.complete?
> When did the system update the cache? When entity.property.set and uow.complete?
> Thanks a lot.

View raw message