redis简单的读写
2016-04-15 11:24
357 查看
redis简单的读写记录key value。首先要引用redes 算了,还是代码来说话吧。麻烦。
/// 缓存到Redis中
/// </summary>
/// <param name="key">key值</param>
/// <param name="danhaoList">详细的信息</param>
public static void EnqueueList(string key, string obj)
{
using (var client = poolreds.GetClient())
{
//队列使用
if (obj != null)
{
client.AddItemToList(key, obj);
}
}
}
// //<summary>
// //读取当前
// //</summary>
// //<param name="key"></param>
// //<returns></returns>
public static string DequeueModel(string key)
{
using (var client = poolreds.GetClient())
{
string danhao = client.GetItemFromList(key, 0);
return danhao;
}
} // //<summary>
// //判断当前是否有记录
// //</summary>
// //<param name="key"></param>
// //<returns></returns>
public static long GetListCount(string key)
{
using (var client = poolreds.GetClient())
{
long count = client.GetListCount(key);
return count;
}
} 这个是插入到一个list里面。如图
插入到统一的kjgz2016-04-08 list里面。list的里面又可以插入很多记录。一个key 对于很多value。可以记录很多东西。很好用的一种排版不是很好啊。嘿嘿。。。 后面还有哦
链接方式 //引用 public static PooledRedisClientManager poolreds; //这个对应的redis的库 static int port = 1; static RedisPool() { try { // 对于的redis库的 密码 ip 端口 RedisUrlopenid=“密码@ip:端口” poolreds = new PooledRedisClientManager(port, new string[] { ConfigurationManager.AppSettings["RedisUrlopenid"] }); } catch (Exception ex) { } }对于上面的:写/// <summary>
/// 缓存到Redis中
/// </summary>
/// <param name="key">key值</param>
/// <param name="danhaoList">详细的信息</param>
public static void EnqueueList(string key, string obj)
{
using (var client = poolreds.GetClient())
{
//队列使用
if (obj != null)
{
client.AddItemToList(key, obj);
}
}
}
对于上面的:读
// //<summary>
// //读取当前
// //</summary>
// //<param name="key"></param>
// //<returns></returns>
public static string DequeueModel(string key)
{
using (var client = poolreds.GetClient())
{
string danhao = client.GetItemFromList(key, 0);
return danhao;
}
} // //<summary>
// //判断当前是否有记录
// //</summary>
// //<param name="key"></param>
// //<returns></returns>
public static long GetListCount(string key)
{
using (var client = poolreds.GetClient())
{
long count = client.GetListCount(key);
return count;
}
} 这个是插入到一个list里面。如图
插入到统一的kjgz2016-04-08 list里面。list的里面又可以插入很多记录。一个key 对于很多value。可以记录很多东西。很好用的一种排版不是很好啊。嘿嘿。。。 后面还有哦
相关文章推荐
- Redis中的压缩列表
- tomcat配置tomcat-redis-session-manager
- redis的安装
- 各种nosql数据库的比较Cassandra,MongoDB,CouchDB,Redis,Riak,HBase
- RabbitMQ与Redis队列对比
- openresty--基于redis实现一个动态路由
- 复习redis(二)
- Redis实现信息已读未读状态提示
- Mac OS X安装Redis
- redis设计与实现---index
- redis的观察者模式----------发布订阅功能
- windows下安装redis
- 在Ubuntu Kylin14上安装Redis
- 在laravel中用redis与nodejs的socket通讯
- mysql数据向Redis快速导入
- redis 学习笔记
- Java操作Redis--Jedis
- Windows下Redis的安装使用
- Hadoop、Spark、HBase与Redis的适用性见解
- Redis内存使用优化与存储