Inheritance: ValueObjectBase
示例#1
0
        /// <summary>
        /// 객체를 캐시에 저장하기 위해, <see cref="SharedCacheEntry"/> 인스턴스로 빌드합니다.
        /// </summary>
        /// <param name="key"></param>
        /// <param name="value"></param>
        /// <returns></returns>
        private SharedCacheEntry SerializeValue(object key, object value)
        {
            var entry = new SharedCacheEntry(GetCacheId(key), null);

            var serialized = Serializer.Serialize(value);

            if (serialized.Length > CompressThreshold)
            {
                serialized         = Compressor.Compress(serialized);
                entry.IsCompressed = true;
            }
            entry.Value = serialized;
            return(entry);
        }
示例#2
0
        /// <summary>
        /// 캐시에 저장된 <see cref="SharedCacheEntry"/>에서 원본 값을 추출합니다.
        /// </summary>
        /// <param name="entry"></param>
        /// <returns></returns>
        private static object DeserializeValue(SharedCacheEntry entry)
        {
            entry.ShouldNotBeNull("entry");

            byte[] value = entry.Value;

            if (value == null)
            {
                return(null);
            }

            if (entry.IsCompressed)
            {
                value = Compressor.Decompress(value);
            }

            return(Serializer.Deserialize(value));
        }
示例#3
0
        /// <summary>
        /// 캐시에 저장된 <see cref="SharedCacheEntry"/>에서 원본 값을 추출합니다.
        /// </summary>
        /// <param name="entry"></param>
        /// <returns></returns>
        private static object DeserializeValue(SharedCacheEntry entry) {
            entry.ShouldNotBeNull("entry");

            byte[] value = entry.Value;

            if(value == null)
                return null;

            if(entry.IsCompressed)
                value = Compressor.Decompress(value);

            return Serializer.Deserialize(value);
        }
示例#4
0
        /// <summary>
        /// 객체를 캐시에 저장하기 위해, <see cref="SharedCacheEntry"/> 인스턴스로 빌드합니다.
        /// </summary>
        /// <param name="key"></param>
        /// <param name="value"></param>
        /// <returns></returns>
        private SharedCacheEntry SerializeValue(object key, object value) {
            var entry = new SharedCacheEntry(GetCacheId(key), null);

            var serialized = Serializer.Serialize(value);
            if(serialized.Length > CompressThreshold) {
                serialized = Compressor.Compress(serialized);
                entry.IsCompressed = true;
            }
            entry.Value = serialized;
            return entry;
        }