public function build(array $attributes)
    {
        // If the object we are building is a value object,
        // we won't be using the instance cache.
        if (!$this->useCache || $this->entityMap->getKeyName() === null) {
            return $this->buildEntity($attributes);
        }

        $instanceCache = $this->mapper->getInstanceCache();

        $id = $this->getPrimaryKeyValue($attributes);

        return $instanceCache->has($id) ? $instanceCache->get($id) : $this->buildEntity($attributes);
    }