Commit graph

50 commits

Author SHA1 Message Date
Timo Tijhof
68a54d6d7a objectcache: Rename WANObjectCache TTL_NONE to TTL_INDEFINITE
"None" has a somewhat unobvious meaning, also ambiguous with "uncachable".

Change-Id: I799de385427aeb8f581d51800606552bdc998252
2015-10-14 17:08:59 -04:00
Aaron Schulz
1a6151e3a6 Caching documentation tweaks and doxygen cleanups
Change-Id: I4b37a6c7d267d4eb0b39b313d92e6c0bf87d460e
2015-10-10 01:06:37 -07:00
Aaron Schulz
968e28f894 Add process cache support to WANObjectCache
* Make getWithSetCallback() accept a TTL field for this
* Make ChangeTag callers use this flag to avoid hundreds of
  duplicate queries at Special:Tags

Change-Id: Ic1ed28294f5d557e02f39a7f20d36766244b9ded
2015-10-10 06:14:50 +00:00
jenkins-bot
9e56569f9f Merge "Minor getWithSetCallback() example formatting tweaks" 2015-10-10 04:55:52 +00:00
Aaron Schulz
17e8bd3f32 Better explain WANObjectCache::TTL_NONE constant
Change-Id: I2ce363c957f35e75a17f05b2160979a6fa4aa642
2015-10-10 00:12:37 +00:00
Aaron Schulz
3c021116e4 Minor getWithSetCallback() example formatting tweaks
Change-Id: I6fc7164770fbbd32374b01d1aa27dbaa9263c940
2015-10-08 15:49:57 -07:00
Aaron Schulz
e5878c522b Update getWithSetCallback() examples to use the new signature
Change-Id: I81916b4d1884bad5d30f689698aa35cdb9f139eb
2015-10-07 21:52:43 -07:00
Aaron Schulz
5aee45ee9e Fix default $oldOpts from 09cbebb224
This fixes the default $oldOpts value for the case when
$opts is given check keys and no $oldOpts value is passed
in. In that case, the getWithSetCallback() method
variable $opts would be null instead of array().

Change-Id: I825062533478b37766511aae1d06dd4b81f8dba1
2015-10-07 20:26:38 -07:00
Timo Tijhof
09cbebb224 WANObjectCache: Change getWithSetCallback() signature to key/ttl/callback/opts
* Put 'checkKeys' param in opts array instead of as a separate parameter.
  It's neat to not have to skip unnamed/positional arguments that are optional.
* Move TTL to be before callback instead of after. This avoids dangling integers
  toward the bottom of a large code block that have no obvious meaning.
  Matches BagOStuff::getWithSetCallback.

Add unit test for lockTSE to confirm

Change-Id: I60d6b64fc5dff14108741bafe801fd1fde16d1df
2015-10-07 18:03:15 -07:00
Aaron Schulz
667e9ef44b Bump WANObjectCache::LOW_TTL to 30
This better handles values that take a long time to
generate. For example if it took 10 sec, then the old
value would not regenerate in time. 30 is a good, high,
value that is the default PHP timeout.

Change-Id: I2e4372bf4c6d28d09347012926d8c0a9deda4183
2015-10-06 23:50:28 -07:00
Aaron Schulz
54758dd160 Change getCacheSetOptions() callers to use "Database"
* This is less verbose that DatabaseBase
* Also add a few WAN cache doc comments

Change-Id: I5b6de6d0ffa06753ea96c50b63db7dae796475dc
2015-10-05 22:06:46 -07:00
Aaron Schulz
db0b9ef264 Make WANObjectCache sets account for slave lag
* This gets lag information that is useful when
  the calling code is about to run queries that
  will have their results cached.
* This is now used in place of trxTimestamp() for
  WANObjectCache set() and getWithSetCallback().
* The WAN cache will use a low TTL if the lag is
  too high to avoid caching stale data for weeks.
* Bumped MAX_COMMIT_DELAY as nothing enforces it.

Bug: T113204
Change-Id: I2a95b4088cff42d6e980351555f81a4b13519e24
2015-10-05 16:45:13 -07:00
Aaron Schulz
7aea96befa objectcache: Add some newlines to WANObjectCache docs
* Doxygen needs this or the paragraph ends up in the
  last bullet point
* Also removed some redundant comments

Change-Id: Ie4bf2b67fff27ecad5f24f55688161fe484c300d
2015-10-01 20:42:16 +00:00
Aaron Schulz
3f3d5a10b9 Cleaned up WANObjectCache toy example code blocks
The list order logic was backwards

Change-Id: Id26e13b69d9e1e6ef132792bdcc693836757cbd8
2015-09-29 23:05:33 -07:00
Aaron Schulz
4ff4296333 Improved getWithSetCallback() docs to have more use cases
Change-Id: I428617c159009f22fa78129c16a8964ac2e830b9
2015-09-29 17:25:38 -07:00
Aaron Schulz
a9665bf4d6 Clarified WAN cache docs by using "datacenter" consistently
Change-Id: I448c57cebd0481809fc17a7c2ac698c73b17dcba
2015-09-28 18:22:52 -07:00
Aaron Schulz
75f06d5294 Added $opts to WANObjectCache::set() to detect snapshot lag
* This can avoid some stale write race conditions
* Made use of this option in a few key places
* HOLDOFF_TTL was also bumped

Change-Id: I83505a59cce0119e456191c3100f7d97bc86bdbf
2015-09-28 23:03:36 +00:00
Aaron Schulz
d02b98b8f3 Updated key WANObjectCache::delete() callers to avoid races
* They now issue the delete() write before COMMIT of
  the relevant DB (or immediately if no trx is active)
* This can avoid some stale write race conditions
* Updated the WAN cache delete() docs

Change-Id: Id54887976051120b76528070d5f2ceb357d57897
2015-09-26 18:02:00 +00:00
Aaron Schulz
859cc75432 Assorted WANObjectCache doc tweaks
Change-Id: If207fc64279e344218d3b617eae7e69f88b23b27
2015-09-26 04:53:58 +00:00
Aaron Schulz
1ed292fa9e Improvements to WANObjectCache::getWithSetCallback()
* If lockTSE is set, make sure it applies during during
  the entire duration of a key being tombstoned. This lets
  regenerations happen during that whole time, which lowers
  the chance of seeing stale data if the DBs are lagged.
* If lockTSE is not set, do not apply tempTTL (for tomstoned keys).
  If traffic is high, a stale value would usually be "stashed" and
  used for 5 seconds. If the lag was only 1 second, then this
  is suboptimal.
* Determine tempTTL from lockTSE as they no longer make sense
  being separate. This makes things easier to understand and
  also makes the lockTSE value account for the last regeneration
  time (via stash key TTL). Since LOCK_TSE << HOLDOFF_TTL, this
  helps avoid stale reads without adding stampede risk.

Change-Id: I3b01f0ec67935a238b30e02e42004fd3b2dcfb9d
2015-09-23 15:24:01 +00:00
jenkins-bot
e3d0743904 Merge "objectcache: Fix some doc bullet points in WANObjectCache" 2015-09-23 05:28:18 +00:00
Aaron Schulz
901dcffd80 objectcache: Fix some doc bullet points in WANObjectCache
Change-Id: Id3e65b0768d45087aaf83ed3f432923c82acc713
2015-09-23 05:17:48 +00:00
Aaron Schulz
c1931c2933 objectcache: Add comments about DB isolation to WANObjectCache
Change-Id: Ic3454d0ebfdb05488dd650f77e09264842caea1c
2015-09-23 05:16:35 +00:00
Aaron Schulz
73b27a3d32 Small cleanups to WANObjectCache
* Added a few comments
* Renamed $locked => $lockAcquired for clarity

Change-Id: I45710974971731205d072a1f4b0f9cb37e2cb2a2
2015-09-17 11:00:23 -07:00
Aaron Schulz
2df6d54182 Moved some WANObjectCache number literals to constants
Change-Id: I848440408b54c1dfd4961c15cc83aad9a1a19425
2015-09-16 10:05:54 -07:00
jenkins-bot
5254ff682c Merge "Clarified WANObjectCache::delete() comments" 2015-09-01 00:44:09 +00:00
Aaron Schulz
8e93245603 objectcache: Correct tempTTL comment for getWithSetCallback()
* This applies regardless of lockTSE

Change-Id: I5adb62fbb956407cd978211a0497e8bd9de3c1a5
2015-08-31 20:52:13 +00:00
Aaron Schulz
274f1009c9 Clarified WANObjectCache::delete() comments
Change-Id: I8c1cffa284cf92461045f9163ff1d1e9bf8c2244
2015-08-31 13:26:22 -07:00
jenkins-bot
a7c124f2e9 Merge "Added $ttl sanity check to WANObjectCache::delete()" 2015-08-25 22:12:35 +00:00
Aaron Schulz
da531a8be5 Fixed "undefined class" IDE errror from INF use in @param
Change-Id: I5d044da0946d046f4a8581445ede39d56973a126
2015-08-24 04:15:28 -07:00
Aaron Schulz
b085d5f9a2 Added $ttl sanity check to WANObjectCache::delete()
Change-Id: I48c80bd6ba5f79c94e87d75816f2e2069200c9aa
2015-08-19 16:37:59 -07:00
jenkins-bot
8a6548ee45 Merge "Added a tombstone comment to WANObjectCache" 2015-08-19 00:46:12 +00:00
Aaron Schulz
6ff5c6afe3 Made WANObjectCache::get() comments more accurate
Change-Id: I531c2dca6b552a6b3732d2506e7373c7d17b4b4c
2015-08-15 12:33:58 -07:00
Aaron Schulz
72c493a3e4 Added a tombstone comment to WANObjectCache
Change-Id: Ia8c2fc4d4bbb741a6cd7aaa6f3ae433e65743b29
2015-08-13 15:54:44 -07:00
Aaron Schulz
7d5f3efa2f objectcache: Add WANObjectCache::resetCheckKey() method
Change-Id: I6f8b97c1f4511534e1ab2656f472adee491f9d9f
2015-07-13 21:25:20 +00:00
Aaron Schulz
84758e6f10 Made WANObjectCache::getCheckKey() automatically init the key
* This still allows If-Modified-Since logic but does not
  need to broadcast initialization values just because a
  key fell out of cache. The value can differ between DCs
  anyway via skew, this just lets them drift more. Actual
  purge events are still broadcasted, which is what matters.
* The User class has now been simplified given this change.
* Added more general comments to getCheckKeyTime().

Change-Id: Ic1f4bbb1947e0d1dd47499c9e9dc86991c30580c
2015-07-02 07:13:22 +00:00
Alex Monk
6a92393760 Set 644 file permissions on some *.php files
Bug: T103754
Change-Id: I2f5bae84463ea849ceae027c17b924779adf8c19
2015-06-27 20:46:05 +00:00
jenkins-bot
5161541d87 Merge "Converted FileBackendStore to using the WAN cache" 2015-05-18 08:34:10 +00:00
Aaron Schulz
60608c1274 Cleanups to WANObjectCache::getWithSetCallback code
* Do not use lock() for tombstoned keys unless lockTSE was set
* Moved the is_callable() check down a bit further
* Also removed one inaccurate comment

Change-Id: I904e0681faa48b1dc2bc2a3c005a29d2f8347065
2015-05-15 06:07:13 +00:00
Aaron Schulz
a2c4237098 Added WANObjectCache::TTL_UNCACHEABLE for uncacheable content
Change-Id: If7b75654c91cc5762cb49d90f40e1b7ea518ebc8
2015-05-13 20:29:17 -07:00
jenkins-bot
79697edcbf Merge "Allow for dynamic TTLs in getWithSetCallback()" 2015-05-14 03:23:36 +00:00
Aaron Schulz
e941534195 objectcache: Add WANObjectCache::TTL_NONE constant for readability
Change-Id: I07592ebb2794a7a8efc0fd1d718c1b5ca3d9b83f
2015-05-13 13:37:11 +00:00
Aaron Schulz
4db819011a Allow for dynamic TTLs in getWithSetCallback()
* This gives it better parity with BagOStuff::set()
* Also updated some doc comments

Change-Id: Ib94b97715fae901bac1750656e3dc7501919d6d2
2015-05-12 13:04:53 -07:00
Aaron Schulz
9b7d95fc96 More "check key" doc comments
Change-Id: Ide66bc396e811776a58fd6aa7c1af2337ea185bd
2015-05-11 19:15:35 -07:00
Aaron Schulz
77a949dea6 Added more lockTSE comments to getWithSetCallback()
Change-Id: I6ac56784bc231d7dec7869c6d2b901341bde6e9b
2015-05-06 20:38:53 -07:00
Aaron Schulz
48cffdff82 Converted FileBackendStore to using the WAN cache
Bug: T93141
Change-Id: I76efb0dc45a697c5fdfc50932e1198a6d663a445
2015-04-30 01:30:38 +00:00
Aaron Schulz
fcd0231305 Made getWithSetCallback doc comment clearer
Change-Id: I68c3929691c886bcfee32499a6058f01f69ea63c
2015-04-29 11:45:42 -07:00
Aaron Schulz
a2ea6116af Fixed some <code> tags for doxygen
Change-Id: I550b8760556e4916ee9b63ee244bbbcb4d926142
2015-04-29 06:01:59 +01:00
Kunal Mehta
8f0ed9c838 Fix @return documentation in WANObjectCache::prefixCacheKeys()
Change-Id: Iff27ad3b034b4702f329437950b69731de29171c
2015-04-28 04:17:28 +00:00
Aaron Schulz
c7bf955bca Moved WAN cache and relayer to /libs
Change-Id: I9586d22890ce1cda7f74869ff701de73d65eaaef
2015-04-27 12:35:58 -07:00
Renamed from includes/objectcache/WANObjectCache.php (Browse further)