Files
UnrealEngineUWP/Engine/Source/Developer/DerivedDataCache/Private/DerivedDataCacheKey.cpp
Devin Doucette 7bd5b197e8 DDC: Added the new cache interface UE::DerivedData::ICache
ICache will eventually replace the existing cache access functions on FDerivedDataCacheInterface. The notable differences relative to the existing interface are:

- It is asynchronous with completion callbacks by default, and allows waiting when necessary.
- It allows batch requests containing multiple cache records by default.
- It uses a structured cache key made up of a bucket name and a hash.
- It supports prioritization and cancellation of requests.
- It supports structured cache records with metadata.
- It supports attachments to allow multi-part cache records.
- It uses a typed request object instead of an opaque integer handle.
- It provides cache policy flags to control how to query and store cache records, and which parts of a cache record to fetch.

This initial implementation of ICache is totally synchronous and uses the existing cache backends for storage.

#rb Zousar.Shaker

[CL 15152247 by Devin Doucette in ue5-main branch]
2021-01-21 01:57:01 -04:00

73 lines
1.9 KiB
C++

// Copyright Epic Games, Inc. All Rights Reserved.
#include "DerivedDataCacheKey.h"
#include "Algo/AllOf.h"
#include "Misc/StringBuilder.h"
#include "UObject/NameTypes.h"
namespace UE
{
namespace DerivedData
{
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
FCacheBucket::FCacheBucket(FStringView Name)
: Index(FName(Name).GetDisplayIndex().ToUnstableInt())
{
check(Algo::AllOf(Name, FChar::IsAlnum));
}
void FCacheBucket::ToString(FAnsiStringBuilderBase& Builder) const
{
verify(FName::CreateFromDisplayId(FNameEntryId::FromUnstableInt(Index), 0).TryAppendAnsiString(Builder));
}
void FCacheBucket::ToString(FWideStringBuilderBase& Builder) const
{
FName::CreateFromDisplayId(FNameEntryId::FromUnstableInt(Index), 0).AppendString(Builder);
}
bool FCacheBucketLexicalLess::operator()(FCacheBucket A, FCacheBucket B) const
{
return FNameEntryId::FromUnstableInt(A.ToIndex()).LexicalLess(FNameEntryId::FromUnstableInt(B.ToIndex()));
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void FCacheKey::ToString(FAnsiStringBuilderBase& Builder) const
{
Builder << Bucket;
if (!Bucket.IsNull())
{
Builder << "/" << Hash;
}
}
void FCacheKey::ToString(FWideStringBuilderBase& Builder) const
{
Builder << Bucket;
if (!Bucket.IsNull())
{
Builder << TEXT("/") << Hash;
}
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void FCacheAttachmentKey::ToString(FAnsiStringBuilderBase& Builder) const
{
Builder << Key << '/' << Hash;
}
void FCacheAttachmentKey::ToString(FWideStringBuilderBase& Builder) const
{
Builder << Key << TEXT('/') << Hash;
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
} // DerivedData
} // UE