MediaWiki  1.34.0
SerializedValueContainer.php
Go to the documentation of this file.
1 <?php
2 
9  const SCHEMA = '__svc_schema__';
10  const SCHEMA_UNIFIED = 'DAAIDgoKAQw'; // 64 bit UID
11  const SCHEMA_SEGMENTED = 'CAYCDAgCDw4'; // 64 bit UID
12 
13  const UNIFIED_DATA = '__data__';
14  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 }
SerializedValueContainer\SCHEMA
const SCHEMA
Definition: SerializedValueContainer.php:9
$serialized
foreach( $res as $row) $serialized
Definition: testCompression.php:81
SerializedValueContainer\instanceOf
static instanceOf( $value, $schema)
Definition: SerializedValueContainer.php:59
SerializedValueContainer\isSegmented
static isSegmented( $value)
Definition: SerializedValueContainer.php:50
SerializedValueContainer\SCHEMA_SEGMENTED
const SCHEMA_SEGMENTED
Definition: SerializedValueContainer.php:11
SerializedValueContainer\UNIFIED_DATA
const UNIFIED_DATA
Definition: SerializedValueContainer.php:13
SerializedValueContainer\SCHEMA_UNIFIED
const SCHEMA_UNIFIED
Definition: SerializedValueContainer.php:10
SerializedValueContainer\newUnified
static newUnified( $serialized)
Definition: SerializedValueContainer.php:20
SerializedValueContainer\SEGMENTED_HASHES
const SEGMENTED_HASHES
Definition: SerializedValueContainer.php:14
SerializedValueContainer
Helper class for segmenting large cache values without relying on serializing classes.
Definition: SerializedValueContainer.php:8
SerializedValueContainer\isUnified
static isUnified( $value)
Definition: SerializedValueContainer.php:42
SerializedValueContainer\newSegmented
static newSegmented(array $segmentHashList)
Definition: SerializedValueContainer.php:31