示例#1
0
        private static CacheDeterminism ReadDeterminism(byte[] determinismBytes, byte[] oldDeterminismBytes)
        {
            var determinism        = CacheDeterminism.Deserialize(determinismBytes);
            var oldDeterminismGuid = new Guid(oldDeterminismBytes);

            // If the old guid was ToolDeterministic, we need to keep it that way.
            if (oldDeterminismGuid == CacheDeterminism.Tool.Guid)
            {
                return(CacheDeterminism.Tool);
            }

            // If the old guid was SinglePhaseNonDeterministic, we need to keep it that way.
            if (oldDeterminismGuid == CacheDeterminism.SinglePhaseNonDeterministic.Guid)
            {
                return(CacheDeterminism.SinglePhaseNonDeterministic);
            }

            // The newer code always sets the old "Determinism" column to the same determinism guid when it writes a new value,
            // so if we read here that the determinism from the old column is different from
            // the new "SerializedDeterminism" column's guid then the ContentHashList in this row was inserted by the
            // old code and the new column's Determinism value is no longer valid. In that case, we return None.
            return(oldDeterminismGuid == determinism.EffectiveGuid
                ? determinism
                : CacheDeterminism.None);
        }
示例#2
0
        /// <inheritdoc />
        public ContentHashListWithDeterminism AsContentHashList(RedisValue value)
        {
            const int partCount = 5;
            var       parts     = value.ToString().Split(new[] { RedisValueSeparator }, partCount, StringSplitOptions.None);

            Contract.Assert(parts.Length == partCount);
            var determinism = CacheDeterminism.Deserialize(HexUtilities.HexToBytes(parts[0]));
            var payload     = parts[3] == RedisValueExistsSemaphore?HexUtilities.HexToBytes(parts[4]) : null;

            var hashList = parts[1] == RedisValueExistsSemaphore?ContentHashList.Deserialize(parts[2], payload) : null;

            return(new ContentHashListWithDeterminism(hashList, determinism));
        }