C# nosql之redis初体验
Redis官方是不支持windows的,只是 Microsoft Open Tech group 在 GitHub上开发了一个Win64的版本,项目地址是:
https://github.com/MSOpenTech/redis
下载redis windows版本
cmd进入下载目录
执行安装命令
运行 redis-server.exe redis.conf conf是配置文件 可根据自己需要进行修改 第一次折腾先不搞太负责 入门再说
如果想方便的话,可以把redis的路径加到系统的环境变量里,这样就省得再输路径了,后面的那个redis.conf可以省略,如果省略,会启用默认的
redis是运行于内存中的nosql数据库 没有固定的表结构 采用key-value的方式存储 支持自定义数据类型 使用非常方便 使用json存储

本次使用的是 Redis client for the Redis NoSQL DB 这个类库 对于所有类型 该类库都是采用序列化方式存储的 可以直接在vs nuget中直接获取到
using ServiceStack.Redis;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks; namespace WindowsFormsApplication1
{
public class RedisOperatorBase
{
PooledRedisClientManager _prcm;
protected IRedisClient Redis { get; private set; }
private bool _disposed = false;
public RedisOperatorBase()
{
List<string> writeServerList = new List<string> {"127.0.0.1:6379" };
List<string> readServerList = new List<string> { "127.0.0.1:6379" }; _prcm = new PooledRedisClientManager(writeServerList, readServerList,
new RedisClientManagerConfig
{
MaxWritePoolSize = 50,
MaxReadPoolSize = 50,
AutoStart = false, });
_prcm.Start();
Redis= _prcm.GetClient(); } public T read<T>()
{ return Redis.Get<T>("test"); } public void write<T>(T t)
{ Redis.Set<T>("test",t);
} public void save() {
Redis.Save();
} }
/// <summary>
///
/// </summary>
public class test {
public int a { get; set; }
public int b { get; set; }
}
}
static void Main()
{
RedisOperatorBase redis = new RedisOperatorBase();
redis.write<test>(new test() {a=1,b=2 });
Stopwatch watch = new Stopwatch();
watch.Start();
for (int i = 0; i < 5000; i++)
{
test test = redis.read<test>(); }
watch.Stop();
Console.WriteLine(watch.Elapsed);
Console.Read();
}
保持2个数据库直接的同步 修改从数据库配置文件项
#slaveof <masterip> <masterport> 取消注释 #号 改为 slaveof 127.0.0.1 6379 后面为绑定的主数据库ip与端口
C# nosql之redis初体验的更多相关文章
- nginx+lua+redis初体验
1.下载nginx.lua.redis nginx下载地址 wget http://nginx.org/download/nginx-1.8.0.tar.gz lua下载地址 wget http:/ ...
- redis学习心得之一【安装redis初体验】
在linux下安装redis 说起这个比mysql的安装过程简单多乐,它不需要configure,只需要解压之后make就可以,无需make install ~$ wget http://redis. ...
- Redis初体验
简介 Redis是一个速度非常快的非关系型数据库,它不仅性能强劲,而且还具有复制特性以及为解决问题而生的独一无二的数据模型.作为键值型数据库,Redis支持5中数据类型:字符串,列表,集 ...
- Golang访问Redis初体验
go语言的client在redis官网上有很多l客户端,个人感觉redigo使用起来更人性化,重要的是源代码结构很清晰,重要的是支持管道.发布和订阅.连接池等等,所以我选择redigo作为尝试. 1. ...
- 01.Redis 初体验
0. Redis安装 官网下载Redis 解压缩 make make install 安装后的执行命令被保存在了/usr/local/bin目录下 1. 配置文件:redis.conf daemoni ...
- Spring boot集成redis初体验
pom.xml: <?xml version="1.0" encoding="UTF-8"?> <project xmlns="ht ...
- Spring Boot + Redis 初体验
本文测试环境: Spring Boot 2.1.4.RELEASE + Redis 5.0.4 + CentOS 7 让程序先 run 起来 安装及配置 Redis 参考: How To Instal ...
- 分布式NoSQL数据库MongoDB初体验-v5.0.5
概述 定义 MongoDB官网 https://www.mongodb.com/ 社区版最新版本5.0,其中5.2版本很快也要面世了 MongoDB GitHub源码 https://github.c ...
- 【Python3爬虫】爬取美女图新姿势--Redis分布式爬虫初体验
一.写在前面 之前写的爬虫都是单机爬虫,还没有尝试过分布式爬虫,这次就是一个分布式爬虫的初体验.所谓分布式爬虫,就是要用多台电脑同时爬取数据,相比于单机爬虫,分布式爬虫的爬取速度更快,也能更好地应对I ...
随机推荐
- 【DFS】【贪心】Codeforces Round #411 (Div. 1) C. Ice cream coloring
对那个树进行dfs,在动态维护那个当前的冰激凌集合的时候,显然某种冰激凌仅会进出集合各一次(因为在树上形成连通块). 于是显然可以对当前的冰激凌集合贪心染色.暴力去维护即可.具体实现看代码.map不必 ...
- 【预处理】Codeforces Round #407 (Div. 2) C. Functions again
考虑枚举每个子串开头的位置,然后答案转化成询问这个位置之后 哪个位置的前缀和 - 这位置的前缀和 最大(当然是已经把绝对值和正负的情况处理好了,可以发现按奇偶,这个序列只有两种情况),只需要预处理这两 ...
- 修改request的parameter的几种方式(转载)
转载地址:https://blog.csdn.net/xieyuooo/article/details/8447301
- HDU 4584 Building bridges (水题)
Building bridges Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 65535/32768 K (Java/Others) ...
- 【docker】【redis】2.docker上设置redis集群---Redis Cluster部署【集群服务】【解决在docker中redis启动后,状态为Restarting,日志报错:Configured to not listen anywhere, exiting.问题】【Waiting for the cluster to join...问题】
参考地址:https://www.cnblogs.com/zhoujinyi/p/6477133.html https://www.cnblogs.com/cxbhakim/p/9151720.htm ...
- 轻量级web服务器lighttpd的编译及配置(for x86-linux)
转自:http://blog.163.com/ljf_gzhu/blog/static/131553440201211522317367/ 备注: PC Linux:Ubuntu-10.10 Linu ...
- Storm常见模式——分布式RPC
Storm常见模式——分布式RPC 本文翻译自:https://github.com/nathanmarz/storm/wiki/Distributed-RPC,作为学习Storm DRPC的资料,转 ...
- 使用免安装版本在windows上手动安装PostgreSQL
PostgreSQL支持管理员直接手动安装数据库,给用户提供了更大的方便. 1. 在PostgreSQL官方网站上下载免安装二进制的包,名字类似于postgresql-*.*.*.*-bina ...
- scikit-learn(window,linux)安装
scikit-learn是python的机器学习库 记录下载window中和linux中如何下载scikit-learn 方法一 直接下载Anaconda 这是一个非常齐全的python发行版本,里面 ...
- TensorFlow------单层(全连接层)实现手写数字识别训练及测试实例
TensorFlow之单层(全连接层)实现手写数字识别训练及测试实例: import tensorflow as tf from tensorflow.examples.tutorials.mnist ...