+ /**
+ * @param string|int $key
+ * @param string|int $field
+ * @param mixed $value
+ * @param float $initRank
+ */
+ public function setField( $key, $field, $value, $initRank = self::RANK_TOP ) {
+ if ( $this->has( $key ) ) {
+ $this->ping( $key );
+ } else {
+ $this->set( $key, [], $initRank );
+ }
+
+ if ( !is_array( $this->cache[$key] ) ) {
+ throw new UnexpectedValueException( "The value of '$key' is not an array." );
+ }
+
+ $this->cache[$key][$field] = $value;
+ $this->timestamps[$key][self::FIELDS][$field] = $this->getCurrentTime();
+ }
+
+ /**
+ * @param string|int $key
+ * @param string|int $field
+ * @param float $maxAge Ignore items older than this many seconds [optional] (since 1.32)
+ * @return bool
+ */
+ public function hasField( $key, $field, $maxAge = 0.0 ) {
+ $value = $this->get( $key );
+ if ( !is_array( $value ) || !array_key_exists( $field, $value ) ) {
+ return false;
+ }
+
+ return ( $maxAge <= 0 || $this->getAge( $key, $field ) <= $maxAge );
+ }
+
+ /**
+ * @param string|int $key
+ * @param string|int $field
+ * @param float $maxAge Ignore items older than this many seconds [optional] (since 1.32)
+ * @return mixed Returns null if the key was not found or is older than $maxAge
+ */
+ public function getField( $key, $field, $maxAge = 0.0 ) {
+ if ( !$this->hasField( $key, $field, $maxAge ) ) {
+ return null;
+ }
+
+ return $this->cache[$key][$field];
+ }
+