Book
  • Introduction
  • Welcome !!
  • Chapter 1: The mobile ecosystem
    • Fragmentation is the devil
    • There is more than one type of mobile app
    • ... more than one type of app
    • ... one type of app
    • Under pressure (ee da de da de) !!
    • Further reading!!
  • Chapter 2: Let's start with design thinking
    • A taste of design thinking
    • The five steps
    • Design for everybody
    • Accessibility in mobile apps
  • Chapter 3: Give me a context and I will give you an app
    • Users
    • Personas? Users ? What is the difference?
    • Please, help me to model the context
    • The context canvas
  • Chapter 4: Powerful models
    • Data architecture is the foundation of analytics
    • From data to information and knowledge
    • Information/Knowledge in our mobile ecosystem
    • Questions to ask yourselves when building and classifying questions
    • The visualization-data map
    • On the scene: describing how personas interact with your app
  • Chapter 5: A GUI is better than two thousand words
    • 'Good to Go:' Let's explore the Design Systems
    • Designing GUI Mocks
    • No prototype... no deal
  • Chapter 6: About mobile operating systems ... and other deamons
    • The Android OS ... son of LINUX
    • iOS son of Darwin? or is it iOS son of UNIX?
    • Kernels
  • Chapter 7: Yes, software architecture matters !!
    • Self-test time
    • About design and design constraints
    • Architects' mojo: styles and patterns
    • What you need is a tactic !!
    • Self-test time 2 (for real)
    • Further reading
  • Chapter 8: Finally... coding
    • MVC, MVVM, MV*, MV...What?
    • Programming models: the Android side
    • Hello Jetpack, my new friend... An Android Jetpack Introduction
    • Programming models: the iOS side
    • Controllers and more controllers
    • Flutter son of... simplicity
    • Programming models: Flutter?
    • Flutter: State matters... Let´s start simple
    • Flutter: State matters... Complex stuff ahead
    • Micro-optimizations
  • Chapter 9: Data pipeline
    • Generalities data pipelines
    • Data storage types
    • Types of data pipelines
  • Chapter 10: Error Retrieving Chapter 10
    • Eventual Connectivity on Mobile Apps
    • How to handle it on Android
  • Chapter 11: The jewel in the crown: Performance
    • As fast as a nail
    • Memory bloats
    • Energy leaks
    • Final thoughts
  • Chapter 12. Become a performance bugs exterminator
    • Weak or strong?
    • Micro-optimizations
    • The single thread game !!
    • Using multi-threading like a boss !!
    • Caching
    • Avoiding memory bloats
    • Further readings
Powered by GitBook
On this page
  1. Chapter 12. Become a performance bugs exterminator

Caching

(By Mario Linares-Vásquez)


All right. Let´s talk again about the single-thread game from Section 11.3. Remember that in the game there was an action requesting for a math operation: "Calculate sqrt(35323554545345345345345345345)". If you are doing the operation manually and you get the request action, it would be cool if you have the result in a notebook or a post-it, so you do not have to expend again "computational power" recalculating the value. The notebook or the post-it is just a form of "cache", a very simple one.

Caching is a technique used in computing to store data in a temporal storage (i.e., cache) with the purpose of serving that data faster for incoming future requests (asking for the same data). Caching can be done directly by hardware components, or programmatically as part of the architecture of a software system. Among the benefits of using caching you can find improvements on application performance in terms of latency, response time, and IOPS (input/output operations per second), reduction of energy consumption, and reduction of the load on the backend. The key of caching is on having temporary storage that is significantly faster than re-calculating the data.

Note that cache is not only for data generated with a computation, but also for resources that are accessed locally or via a backend request such as images, documents, or result sets.

This sounds like a pretty good strategy to be widely used in apps, right? Yes; however, caching can not be used with every piece of data you have in your app. Look, because temporary storage is faster than persistent storage (i.e., disk), cache is more expensive and consequently smaller. Therefore, cache is often kept in RAM, which means, you have a reduce set of memory slots for caching. So, how to decide what you keep in cache?

PreviousUsing multi-threading like a boss !!NextAvoiding memory bloats

Last updated 1 year ago