logo

Caching in Playorm

Caching in Playorm

 

This project source code is available on github at https://github.com/deanhiller/playorm.

  • Playorm cache results from the database. Caching in Playorm is very similar to caching in hibernate. There are really two caches going on which may be called the write cache and the read cache.

    The write cache is that when someone do a put(Object entity), put(Object entity), etc. etc. Playorm keep caching those puts in the background in a class called NoSqlWriteCacheImpl. When flush is called, this cache is emptied out and cleared. There is no way to clear this cache without flushing it.

    Note:

    • Calling clear does NOT clear this cache, only calling flush does so don’t do a put if you don’t want to write something.
    • This cache is PER NoSqlEntityManager.

     

    Then the read cache is in a class called NoSqlReadCacheImpl. This cache is just like hibernate’s 1st level cache and is PER NoSqlEntityManager just like hibernate. When the stuff is read in, it goes through this layer and is cached and as that stuff is read in again, it is read form the cache instead of going to the nosql database. e.g. You get a tshirt and then get it’s User(say bob) and then you get some other object and get it’s User which happens to be Bob.This results in a cache hit and happens more frequently than one would expect as they query stuff.

    Note:

    • The NoSqlReadCache is completely avoided when running any NoSqlQuery
    • It is only used on the find(Class c, List keys) and find(Class c, Object key) methods.

 

 << Back to Documentation Index