Navigation

Recent site activity

Nexus Documentation‎ > ‎Development‎ > ‎

Caching Data

With the help of ADOdb, Nexus approaches caching in an aggressive way.  That is to say, that almost every single database query is cached to disk.  Cached data is flushed in one of two ways:


  1. Code is explicitly called that flushes a particular query's results from the cache
  2. Some number of seconds (15 at the time of this writing) elapses

The idea here is that is that the more we limit access to the database, the smoother the user's experience is going to be.  The downside is that if we don't catch everywhere that the database is updated a user could see out of date data.  To avoid this problem, a system has been put in place that makes it easy for those parts of the code that alter data in the database to mark the tables that have been affected as 'changed'.  Code which attempts to retrieve data from these places will have consequently know to flush the cache of that query before executing the query again.  It is a lazy update system meaning that when data is changed in the database and the cache is invalidated, the cache is not flushed immediately.  The flushing occurs at the time that the new request for data comes through the pipeline.  The thinking there is that if you have to spend the time to get the data, clearing out the data on disk adds a negligible amount of time to what is a much larger operation.