MediaWiki REL1_35
SerializedValueContainer.php
Go to the documentation of this file.
1<?php
2
9 private const SCHEMA = '__svc_schema__';
10 private const SCHEMA_UNIFIED = 'DAAIDgoKAQw'; // 64 bit UID
11 private const SCHEMA_SEGMENTED = 'CAYCDAgCDw4'; // 64 bit UID
12
13 public const UNIFIED_DATA = '__data__';
14 public const SEGMENTED_HASHES = '__hashes__';
15
20 public static function newUnified( $serialized ) {
21 return (object)[
22 self::SCHEMA => self::SCHEMA_UNIFIED,
23 self::UNIFIED_DATA => $serialized
24 ];
25 }
26
31 public static function newSegmented( array $segmentHashList ) {
32 return (object)[
33 self::SCHEMA => self::SCHEMA_SEGMENTED,
34 self::SEGMENTED_HASHES => $segmentHashList
35 ];
36 }
37
42 public static function isUnified( $value ) {
43 return self::instanceOf( $value, self::SCHEMA_UNIFIED );
44 }
45
50 public static function isSegmented( $value ) {
51 return self::instanceOf( $value, self::SCHEMA_SEGMENTED );
52 }
53
59 private static function instanceOf( $value, $schema ) {
60 return (
61 $value instanceof stdClass &&
62 property_exists( $value, self::SCHEMA ) &&
63 $value->{self::SCHEMA} === $schema
64 );
65 }
66}
Helper class for segmenting large cache values without relying on serializing classes.
static newSegmented(array $segmentHashList)
static instanceOf( $value, $schema)
foreach( $res as $row) $serialized