0) { // Obtain the item's data from cache. $cachedData = static::fetchCachedData($filter); if ($cachedData === null) { $userId = (static::$indexCacheByUser === true) ? $config['id_user'] : null; // Delete expired data cache. static::clearCachedData( [ 'vc_item_id' => $filter['id'], 'vc_id' => $filter['id_layout'], 'user_id' => $userId, ] ); // Obtain the item's data from the database. $data = static::fetchDataFromDB($filter); // Save the item's data in cache. static::saveCachedData( [ 'vc_item_id' => $filter['id'], 'vc_id' => $filter['id_layout'], 'user_id' => $userId, 'expiration' => $filter['cache_expiration'], ], $data ); } else { $data = $cachedData; } } else { $data = static::fetchDataFromDB($filter); } return static::fromArray($data); } }