https://www.jianshu.com/p/4a5ebe3c6dbd
配置
命令行执行 redis-server.exe redis.windows.conf
命令行执行
配置windows 服务自启动Redis
redis-server.exe --service-install redis.windows.conf --loglevel verbose
删除服务执行 sc delete Redis
redis.windows.conf配置文件中开启了密码验证
客户端连接Redis
StackExchange.Redis 连接Redis简单例子
var conn = ConnectionMultiplexer.Connect("127.0.0.1:6379,password=654321");
var database = conn.GetDatabase(0);
string value = "lwlg";
database.StringSet("key", value);
Console.WriteLine(database.StringGet("key"));
读取Redis存储的图片解码Base64并显示到pictureBox上面
private void MyMethod()
{
pictureBox1.Image = null;
sw.Restart();
var database = conn.GetDatabase(0);
string strbase = database.StringGet("XXX.png");
Console.WriteLine($"1显示耗时{sw.ElapsedMilliseconds}ms");
sw.Restart();
MikValSor.Encoding.Base64 base64 = MikValSor.Encoding.Base64.Parse(strbase);
ms = new MemoryStream(base64.ToByteArray());
ms.Seek(0, SeekOrigin.Begin);
pictureBox1.Image = Image.FromStream(ms);
Console.WriteLine($"2显示耗时{sw.ElapsedMilliseconds}ms");
ms.Dispose();
}