class DatabaseVersioner implements VersionerInterface
Records asset revisions one row at a time, so several instances can record different assets at once.
{\Flarum\Frontend\Compiler\FileVersioner} keeps the whole map in a single JSON value, which means every write is a read-modify-write of all of it: a writer carrying a snapshot taken before someone else's write silently erases that write when it saves. Measured across two ECS tasks writing twenty assets each, half the writes were lost; across six local processes, 83% were. Because {[\Flarum\Frontend\Compiler\RevisionCompiler::getUrl()}](../../../Flarum/Frontend/Compiler/RevisionCompiler.html) only recompiles when a revision is *missing*, a lost revision is not noticed — it simply stays wrong until the next admin action. Here each revision is its own row, keyed by the asset's path, so a write touches nothing else and there is no shared value to clobber. Reads are memoised for the lifetime of the instance, matching FileVersioner: rendering a page reads the map around thirty times and individual revisions around sixty-five times through one shared instance, and every one of those would otherwise be a query.
Constants
| TABLE |
|
Methods
Record the current revision of a file, or forget it when null.
Collect writes until {flushWrites()} instead of storing each one as it arrives, so a rebuild that records every asset in turn can store them together.
A batch left open — a caller that never flushed, or a rebuild that threw past its own flush — must still be stored. Reads are answered from the memo while a batch is open, so nothing else would notice the omission until the revisions were missing on the next request.
Details
at
line 51
__construct(ConnectionInterface $database)
at
line 56
void
putRevision(string $file, string|null $revision)
Record the current revision of a file, or forget it when null.
at
line 89
void
deferWrites()
Collect writes until {flushWrites()} instead of storing each one as it arrives, so a rebuild that records every asset in turn can store them together.
Buffered writes are still visible to this instance's own reads, and a read of anything buffered stores the buffer first, so nothing can observe a revision that has been recorded but not saved. An implementation with nothing to gain from batching may treat both methods as no-ops.
at
line 100
__destruct()
A batch left open — a caller that never flushed, or a rebuild that threw past its own flush — must still be stored. Reads are answered from the memo while a batch is open, so nothing else would notice the omission until the revisions were missing on the next request.
at
line 110
void
flushWrites()
Store anything {deferWrites()} collected, and stop deferring.
Safe to call when nothing was deferred.
at
line 151
string|null
getRevision(string $file)
The recorded revision, or null when there is none.