public void ToMap() { var data = new RedisSessionState() { Created = new DateTime(2011, 12, 22, 1, 1, 1, DateTimeKind.Utc), Locked = true, LockId = 999, LockDate = new DateTime(2011, 11, 22, 1, 1, 1, DateTimeKind.Utc), Timeout = 3, Flags = SessionStateActions.InitializeItem }; data.Items["name"] = "Felix"; data.Items["age"] = 1; var map = data.ToMap(); Assert.Equal(date1Bytes, map["created"]); Assert.Equal(new byte[] { 1 }, map["locked"]); Assert.Equal(lockIdBytes, map["lockId"]); Assert.Equal(date2Bytes, map["lockDate"]); Assert.Equal(new byte[] { 3, 0, 0, 0 }, map["timeout"]); Assert.Equal(new byte[] { 1, 0, 0, 0 }, map["flags"]); Assert.Equal(itemsBytes, map["items"]); }
private void UpdateSessionState(IRedisClient client, string key, RedisSessionState state) { UseTransaction(client, transaction => { transaction.QueueCommand(c => c.SetRangeInHashRaw(key, state.ToMap())); transaction.QueueCommand(c => c.ExpireEntryIn(key, TimeSpan.FromMinutes(state.Timeout))); }); }
public void ToMap() { var data = new RedisSessionState() { Created = new DateTime(2011, 12, 22, 1, 1, 1, DateTimeKind.Utc), Locked = true, LockId = 999, LockDate = new DateTime(2011, 11, 22, 1, 1, 1, DateTimeKind.Utc), Timeout = 3, Flags = SessionStateActions.InitializeItem }; data.Items["name"] = "Felix"; data.Items["age"] = 1; var map = data.ToMap(); Assert.Equal(date1Bytes, map["created"]); Assert.Equal(new byte[] { 1 }, map["locked"]); Assert.Equal(lockIdBytes, map["lockId"]); Assert.Equal(date2Bytes, map["lockDate"]); Assert.Equal(new byte[] { 3, 0, 0, 0 }, map["timeout"]); Assert.Equal(new byte[] { 1, 0, 0, 0 }, map["flags"]); Assert.Equal(itemsBytes, map["items"]); }
public static void SetSessionState(this IRedisClient redis, string key, RedisSessionState state) { redis.SetRangeInHashRaw(key, state.ToMap()); }
public static void SetSessionState(this IRedisClient redis, string key, RedisSessionState state) { redis.SetRangeInHashRaw(key, state.ToMap()); }