This method was deprecated in 1.42 and now can be dropped from MW core. In addition, some cosmetic changes in this patch: * Type-hint `isSegmented()` to return bool. Bug: T344521 Change-Id: Idace008e9a961953041bd21b499bfec3f8226142
36 lines
827 B
PHP
36 lines
827 B
PHP
<?php
|
|
|
|
/**
|
|
* Helper class for segmenting large cache values without relying
|
|
* on serializing classes.
|
|
*
|
|
* @since 1.34
|
|
*/
|
|
class SerializedValueContainer {
|
|
private const SCHEMA = '__svc_schema__';
|
|
// 64 bit UID
|
|
private const SCHEMA_SEGMENTED = 'CAYCDAgCDw4';
|
|
public const SEGMENTED_HASHES = '__hashes__';
|
|
|
|
/**
|
|
* @param string[] $segmentHashList Ordered list of hashes for each segment
|
|
* @return stdClass
|
|
*/
|
|
public static function newSegmented( array $segmentHashList ) {
|
|
return (object)[
|
|
self::SCHEMA => self::SCHEMA_SEGMENTED,
|
|
self::SEGMENTED_HASHES => $segmentHashList
|
|
];
|
|
}
|
|
|
|
/**
|
|
* @param mixed $value
|
|
* @return bool
|
|
*/
|
|
public static function isSegmented( $value ): bool {
|
|
return (
|
|
$value instanceof stdClass &&
|
|
( $value->{self::SCHEMA} ?? null ) === self::SCHEMA_SEGMENTED
|
|
);
|
|
}
|
|
}
|