Exemple #1
0
        public byte[] Deserialize(MemcachedResponse response)
        {
            if (response.Header.ResponseStatus != Enums.ResponseStatus.NoError)
            {
                return(default(MemcachedErrorHandler).HandleError <byte[]>(response));
            }

            return(response.Data.ToArray());
        }
Exemple #2
0
        public bool Deserialize(MemcachedResponse response)
        {
            if (response.Header.ResponseStatus != Enums.ResponseStatus.NoError)
            {
                throw new Exception(response.Header.ResponseStatus.ToString());
            }

            return(true);
        }
Exemple #3
0
        public T HandleError <T>(MemcachedResponse response)
        {
            switch (response.Header.ResponseStatus)
            {
            case Enums.ResponseStatus.KeyNotFound:
                throw new KeyNotFoundException("key");

            default:
                throw new Exception(response.Header.ResponseStatus.ToString());
            }
        }
Exemple #4
0
        public string Deserialize(MemcachedResponse response)
        {
            if (response.Header.ResponseStatus == Enums.ResponseStatus.NoError)
            {
                var sequence = response.Data;
                if (sequence.IsSingleSegment)
                {
                    var span = sequence.FirstSpan;
                    return(span.IsEmpty ? string.Empty : encoding.GetString(span));
                }
                else
                {
                    return(GetString(in sequence));
                }
            }

            return(default(MemcachedErrorHandler).HandleError <string>(response));
        }