Skip to content

Rendered cells caching

Qualtagh edited this page Jul 1, 2016 · 1 revision

An LRUCache is used to store images of rendered cells. It's turned off when user scrolls a table and turned on when user finishes scrolling. It's very useful when table cells (and header cells) contain HTML. It's active on columns dragging and resizing. Also, it's used on mouse moving over header cells (causing them to highlight).

If custom cells renderer implements animation then the cache must be turned off. It's on by default.

table.getUI().setCacheUsed( false );

This construct turns off table cells cache. Also, you may want to turn off table header cells cache:

table.getTableHeader().getUI().setCacheUsed( false );

Method isCacheUsed() shows current status of cache usage.

Call clearCellImagesCache() (on table UI or on table header UI) if the cache should be revalidated. Model changes call this method already. UI updates call it too. So, there are few situations when it needs to be called from application code.

Cache key includes model field name, model row, current cell value, cell size and cell states: dragged, rollover, focused, selected and a special drawAsHeader span property (it's explained in Advanced span cells tutorial). If any of these properties change then a cell would be rendered from scratch (and then it would be put to cache for further reuse). So, there's no need to clear images cache if a cell property from this list has changed.

Clear cache if there was a change of cell property that is not listed above. If such changes occur frequently then consider to turn the cache off because the performance may degrade and become lower than without caching.