mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-21 13:00:56 +01:00
aae5f9efd3
Summary: See discussion in D4204. Facebook currently has a 314MB remarkup cache with a 55MB index, which is slow to access. Under the theory that this is an index size/quality problem (the current index is on a potentially-384-byte field, with many keys sharing prefixes), provide a more general index with fancy new features: - It implements PhutilKeyValueCache, so it can be a component in cache stacks and supports TTL. - It has a 12-byte hash-based key. - It automatically compresses large blocks of data (most of what we store is highly-compressible HTML). Test Plan: - Basics: - Loaded /paste/, saw caches generate and save. - Reloaded /paste/, saw the page hit cache. - GC: - Ran GC daemon, saw nothing. - Set maximum lifetime to 1 second, ran GC daemon, saw it collect the entire cache. - Deflate: - Selected row formats from the database, saw a mixture of 'raw' and 'deflate' storage. - Used profiler to verify that 'deflate' is fast (12 calls @ 220us on my paste list). - Ran unit tests Reviewers: vrana, btrahan Reviewed By: vrana CC: aran Differential Revision: https://secure.phabricator.com/D4259
11 lines
479 B
SQL
11 lines
479 B
SQL
CREATE TABLE {$NAMESPACE}_cache.cache_general (
|
|
id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
|
|
cacheKeyHash CHAR(12) BINARY NOT NULL,
|
|
cacheKey VARCHAR(128) NOT NULL COLLATE utf8_bin,
|
|
cacheFormat VARCHAR(16) NOT NULL COLLATE utf8_bin,
|
|
cacheData LONGBLOB NOT NULL,
|
|
cacheCreated INT UNSIGNED NOT NULL,
|
|
cacheExpires INT UNSIGNED,
|
|
KEY `key_cacheCreated` (cacheCreated),
|
|
UNIQUE KEY `key_cacheKeyHash` (cacheKeyHash)
|
|
) ENGINE=InnoDB, COLLATE utf8_general_ci;
|