Skip to Main Content
Delphi High Performance
book

Delphi High Performance

by Primož Gabrijelčič
February 2018
Intermediate to advanced content levelIntermediate to advanced
336 pages
7h 52m
English
Packt Publishing
Content preview from Delphi High Performance

Dynamic cache

A static cache that can only grow has only a limited use. We could, for example, use it to store RTTI properties of types, as access to the RTTI is relatively slow. In most cases, however, a limited-size cache that stores only N most recently used values is more appropriate.

Writing such a cache is quite a tricky operation. First and foremost, we need quick access to a value associated with a specific input (let's call that input a key). In Chapter 1About Performance, we found out that the best way to do that is a hash table (or, in Delphi terms, TDictionary), which has O(1) lookup time.

So that's solved, our cache will store data in a dictionary. But we also have to remove the values from the dictionary (as this cache has ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Delphi Cookbook

Delphi Cookbook

Daniele Teti

Publisher Resources

ISBN: 9781788625456Supplemental Content