24use InvalidArgumentException;
49 foreach ( $entities as $entity ) {
53 $blobsByKey = $this->stash->getMulti( array_keys( $entitiesByKey ) );
56 foreach ( $entitiesByKey as $key => $entity ) {
57 $blob = $blobsByKey[$key] ??
null;
58 $data = is_string(
$blob ) ? json_decode(
$blob,
true ) :
null;
60 $data[self::KEY_PATHS] ?? [],
61 $data[self::KEY_AS_OF] ??
null
70 foreach ( $dataByEntity as $entity => $data ) {
71 if ( !is_array( $data[self::KEY_PATHS] ) || !is_int( $data[self::KEY_AS_OF] ) ) {
72 throw new InvalidArgumentException(
"Invalid entry for '$entity'" );
76 $data[self::KEY_PATHS] = array_values( array_unique( $data[self::KEY_PATHS] ) );
77 sort( $data[self::KEY_PATHS], SORT_STRING );
79 $blob = json_encode( $data, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE );
84 $this->stash->setMulti( $blobsByKey, $ttl, BagOStuff::WRITE_BACKGROUND );
88 public function remove(
$type, $entities ) {
90 foreach ( (array)$entities as $entity ) {
95 $this->stash->deleteMulti(
$keys, BagOStuff::WRITE_BACKGROUND );
101 foreach ( (array)$entities as $entity ) {
106 $this->stash->changeTTLMulti(
$keys, $ttl, BagOStuff::WRITE_BACKGROUND );
116 return $this->stash->makeKey(
"{$type}-dependencies", $entity );
Class representing a cache/ephemeral data store.