You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+21Lines changed: 21 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1252,3 +1252,24 @@ There are multiple levels you can cache that fall into two general categories: *
1252
1252
* Fully-rendered HTML
1253
1253
1254
1254
Generaly, you should try to avoid file-based caching, as it makes cloning and auto-scaling more difficult.
1255
+
1256
+
### Caching at the database query level
1257
+
1258
+
Whenever you query the database, hash the query as a key and store the result to the cache. This approach suffers from expiration issues:
1259
+
1260
+
* Hard to delete a cached result with complex queries
1261
+
* If one piece of data changes such as a table cell, you need to delete all cached queries that might include the changed cell
1262
+
1263
+
### Caching at the object level
1264
+
1265
+
See your data as an object, similar to what you do with your application code. Have your application assemble the dataset from the database into a class instance or a data structure(s):
1266
+
1267
+
* Remove the object from cache if its underlying data has changed
1268
+
* Allows for asynchronous processing: workers assemble objects by consuming the latest cached object
0 commit comments