Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Packages:
- //<?xml version="1.0" encoding="utf-8"?>
- //<packages>
- // <package id="Newtonsoft.Json" version="6.0.3" targetFramework="net45" />
- // <package id="StackExchange.Redis" version="1.0.371" targetFramework="net45" />
- //</packages>
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using StackExchange.Redis;
- using Newtonsoft.Json;
- namespace RedisTest
- {
- public class Model
- {
- public string Name { get; set; }
- public int Age { get; set; }
- }
- public class Program
- {
- static void Main()
- {
- ConnectionMultiplexer redis = ConnectionMultiplexer.Connect("localhost");
- IDatabase redisDB = redis.GetDatabase();
- string complex = JsonConvert.SerializeObject(new Model { Name = "Chris", Age = 43 });
- redisDB.StringSet("1", complex);
- Model value = JsonConvert.DeserializeObject<Model>(redisDB.StringGet("1"));
- Console.WriteLine(value.Age);
- Console.ReadLine();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement