MediaWiki  master
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 (
44  $value instanceof stdClass &&
45  ( $value->{self::SCHEMA} ?? null ) === self::SCHEMA_UNIFIED
46  );
47  }
48 
53  public static function isSegmented( $value ) {
54  return (
55  $value instanceof stdClass &&
56  ( $value->{self::SCHEMA} ?? null ) === self::SCHEMA_SEGMENTED
57  );
58  }
59 }
Helper class for segmenting large cache values without relying on serializing classes.
static newSegmented(array $segmentHashList)
foreach( $res as $row) $serialized