DEV: Implement a faster Discourse.cache

This is a bottom up rewrite of Discourse cache to support faster performance
and a limited surface area.

ActiveSupport::Cache::Store accepts many options we do not use, this partial
implementation only picks the bits out that we do use and want to support.

Additionally params are named which avoids typos such as "expires_at" vs "expires_in"

This also moves a few spots in Discourse to use Discourse.cache over setex
Performance of setex and Discourse.cache.write is similar.
This commit is contained in:
Sam Saffron
2019-11-27 16:11:49 +11:00
parent 0fb497eb23
commit 88ecb650a9
9 changed files with 127 additions and 29 deletions

View File

@ -79,3 +79,17 @@ end
# redis get string marshal: 12789.2 i/s - same-ish: difference falls within error
# Rails read cache string: 10486.4 i/s - 1.25x slower
# Discourse read cache string: 10457.1 i/s - 1.26x slower
#
# After Cache re-write
#
# Comparison:
# redis setex string: 13390.9 i/s
# redis setex marshal string: 13202.0 i/s - same-ish: difference falls within error
# Discourse cache string: 12406.5 i/s - same-ish: difference falls within error
# Rails cache string: 12289.2 i/s - same-ish: difference falls within error
#
# Comparison:
# redis get string: 13589.6 i/s
# redis get string marshal: 13118.3 i/s - same-ish: difference falls within error
# Rails read cache string: 12482.2 i/s - same-ish: difference falls within error
# Discourse read cache string: 12296.8 i/s - same-ish: difference falls within error