/// <summary> /// <para>Writes an object to the store.</para> /// </summary> /// <typeparam name="T"> /// <para>The type of the object.</para> /// </typeparam> /// <param name="keySpace"> /// <para>The key space of the entry.</para> /// </param> /// <param name="key"> /// <para>The key of the entry.</para> /// </param> /// <param name="entry"> /// <para>The entry to write.</para> /// </param> public void Put <T>(DataBuffer keySpace, StorageKey key, StorageEntry <T> entry) { AddKeySpaceInfo <T>(keySpace); using (var item = StreamPool.GetItem()) { var stream = item.Item; stream.Write(BitConverter.GetBytes(entry.Expires.Ticks), 0, sizeof(long)); stream.Write(BitConverter.GetBytes(entry.Updated.Ticks), 0, sizeof(long)); Serializer.Serialize(stream, entry.Instance); Storage.Put(keySpace, key, GetWriteBuffer(stream)); } }
public static ObjectDecorator FromEntry <T>(StorageEntry <T> entry) { if (!entry.IsFound) { throw new ArgumentException(); } return(new ObjectDecorator { Instance = entry.Instance, Expires = entry.Expires, Updated = entry.Updated }); }
void IObjectStorage.Put <T>(DataBuffer keySpace, StorageKey key, StorageEntry <T> entry) { var space = GetSingleKeySpace(keySpace); using (space.Lock(LockType.Write)) { space[key] = new ObjectDecorator { Instance = entry.Instance, Expires = entry.Expires, Updated = entry.Updated }; } }