예제 #1
0
        public ActionResult Index(Data data)
        {
            ModelState.Remove("Value");
            data.Message = string.Empty;
            data.Value = string.Empty;

            if (ModelState.IsValid)
            {
                ConnectionMultiplexer redis = ConnectionMultiplexer.Connect("localhost");
                var db = redis.GetDatabase();

                var value = db.StringGet(data.Key);

                if (value.HasValue)
                {
                    data.Value = value;
                }
                else
                {
                    data.Message = "Key not found.";
                }
            }

            return View(data);
        }
예제 #2
0
        public ActionResult Create(Data data)
        {
            if (ModelState.IsValid)
            {
                string server = "localhost";
                ConnectionMultiplexer redis = ConnectionMultiplexer.Connect(server);
                var db = redis.GetDatabase();

                db.StringSet(data.Key, data.Value);

                return RedirectToAction("Create");
            }

            return View(data);
        }
예제 #3
0
 public ActionResult Index()
 {
     var data = new Data();
     return View(data);
 }