RedisHelper帮助类
using Newtonsoft.Json;
using RedLockNet.SERedis;
using RedLockNet.SERedis.Configuration;
using StackExchange.Redis;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks; namespace 秒杀系统
{
public class RedisHelper
{
private static readonly string RedisHost = "127.0.0.1:6379";
private static readonly string RedisHost1 = "127.0.0.2:6379";
private static readonly string RedisPwd = "sa123456"; private static readonly int RedisDbIndex = ;
private static readonly object LockObject = new object(); private static ConnectionMultiplexer _connection; public static ConnectionMultiplexer Connection
{
get
{
if (_connection == null)
{
lock (LockObject)
{
if (_connection == null || !_connection.IsConnected)
{
var config = new ConfigurationOptions
{
AbortOnConnectFail = false,
ConnectRetry = ,
ConnectTimeout = ,
SyncTimeout = ,
EndPoints = { { RedisHost } },
AllowAdmin = true,
KeepAlive = ,
Password = RedisPwd
};
_connection = ConnectionMultiplexer.Connect(config);
//注册如下事件
_connection.ConnectionFailed += MuxerConnectionFailed;
_connection.ErrorMessage += MuxerErrorMessage;
_connection.InternalError += MuxerInternalError;
}
}
}
return _connection;
}
} public static RedLockFactory redLockFactory; public static RedLockFactory RedlockFactory
{
get
{
if (redLockFactory != null) return redLockFactory;
var multiplexers = new List<RedLockMultiplexer>()
{
Connection
};
var redlockFactory = RedLockFactory.Create(multiplexers);
return redlockFactory;
}
} /// <summary>
/// 获取redis的DB
/// </summary>
/// <returns></returns>
private static IDatabase GetDatabase()
{
if (Connection == null || !Connection.IsConnected)
{
throw new Exception("redis连接有误");
}
return Connection.GetDatabase(RedisDbIndex);
} #region 记录redis的连接日志 /// <summary>
/// 连接失败 , 如果重新连接成功你将不会收到这个通知
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private static void MuxerConnectionFailed(object sender, ConnectionFailedEventArgs e)
{
} /// <summary>
/// redis类库错误
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private static void MuxerInternalError(object sender, InternalErrorEventArgs e)
{
} /// <summary>
/// 发生错误时
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private static void MuxerErrorMessage(object sender, RedisErrorEventArgs e)
{
} #endregion 记录redis的连接日志 #region String #region 同步方法 /// <summary>
/// 保存单个key value
/// </summary>
/// <param name="key">Redis Key</param>
/// <param name="value">保存的值</param>
/// <param name="secondTimeout">过期时间</param>
/// <returns></returns>
public static bool StringSet(string key, string value, int secondTimeout)
{
return Do(db => db.StringSet(key, value, TimeSpan.FromSeconds(secondTimeout)));
} /// <summary>
/// 保存多个key value
/// </summary>
/// <param name="keyValues">键值对</param>
/// <returns></returns>
public static bool StringSet(List<KeyValuePair<RedisKey, RedisValue>> keyValues)
{
List<KeyValuePair<RedisKey, RedisValue>> newkeyValues =
keyValues.Select(p => new KeyValuePair<RedisKey, RedisValue>(p.Key, p.Value)).ToList();
return Do(db => db.StringSet(newkeyValues.ToArray()));
} /// <summary>
/// 保存一个对象
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="key"></param>
/// <param name="obj"></param>
/// <param name="secondTimeout"></param>
/// <returns></returns>
public static bool StringSet<T>(string key, T obj, int secondTimeout)
{
var json = ConvertJson(obj);
return Do(db => db.StringSet(key, json, TimeSpan.FromSeconds(secondTimeout)));
} /// <summary>
/// 获取单个key的值
/// </summary>
/// <param name="key">Redis Key</param>
/// <returns></returns>
public static string StringGet(string key)
{
return Do(db => db.StringGet(key));
} /// <summary>
/// 获取一个key的对象
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="key"></param>
/// <returns></returns>
public static T StringGet<T>(string key)
{
return Do(db => ConvertObj<T>(db.StringGet(key)));
} /// <summary>
/// 为数字增长val
/// </summary>
/// <param name="key"></param>
/// <param name="val">可以为负</param>
/// <returns>增长后的值</returns>
public static long StringIncrement(string key, long val = )
{
return Do(db => db.StringIncrement(key, val));
} /// <summary>
/// 为数字减少val
/// </summary>
/// <param name="key"></param>
/// <param name="val">可以为负</param>
/// <returns>减少后的值</returns>
public static long StringDecrement(string key, long val = )
{
return Do(db => db.StringDecrement(key, val));
} /// <summary>
/// 为数字增长val
/// </summary>
/// <param name="key"></param>
/// <param name="val">可以为负</param>
/// <returns>增长后的值</returns>
public static double StringIncrement(string key, double val = )
{
return Do(db => db.StringIncrement(key, val));
} /// <summary>
/// 为数字减少val
/// </summary>
/// <param name="key"></param>
/// <param name="val">可以为负</param>
/// <returns>减少后的值</returns>
public static double StringDecrement(string key, double val = )
{
return Do(db => db.StringDecrement(key, val));
} #endregion 同步方法 #region 异步方法 /// <summary>
/// 保存单个key value
/// </summary>
/// <param name="key">Redis Key</param>
/// <param name="value">保存的值</param>
/// <param name="secondTimeout">过期时间</param>
/// <returns></returns>
public static async Task<bool> StringSetAsync(string key, string value, int secondTimeout)
{
return await Do(db => db.StringSetAsync(key, value, TimeSpan.FromSeconds(secondTimeout)));
} /// <summary>
/// 保存多个key value
/// </summary>
/// <param name="keyValues">键值对</param>
/// <returns></returns>
public static async Task<bool> StringSetAsync(List<KeyValuePair<RedisKey, RedisValue>> keyValues)
{
List<KeyValuePair<RedisKey, RedisValue>> newkeyValues =
keyValues.Select(p => new KeyValuePair<RedisKey, RedisValue>(p.Key, p.Value)).ToList();
return await Do(db => db.StringSetAsync(newkeyValues.ToArray()));
} /// <summary>
/// 保存一个对象
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="key"></param>
/// <param name="obj"></param>
/// <param name="secondTimeout"></param>
/// <returns></returns>
public static async Task<bool> StringSetAsync<T>(string key, T obj, int secondTimeout)
{
string json = ConvertJson(obj);
return await Do(db => db.StringSetAsync(key, json, TimeSpan.FromSeconds(secondTimeout)));
} /// <summary>
/// 获取单个key的值
/// </summary>
/// <param name="key">Redis Key</param>
/// <returns></returns>
public static async Task<string> StringGetAsync(string key)
{
return await Do(db => db.StringGetAsync(key));
} /// <summary>
/// 获取一个key的对象
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="key"></param>
/// <returns></returns>
public static async Task<T> StringGetAsync<T>(string key)
{
string result = await Do(db => db.StringGetAsync(key));
return ConvertObj<T>(result);
} /// <summary>
/// 为数字增长val
/// </summary>
/// <param name="key"></param>
/// <param name="val">可以为负</param>
/// <returns>增长后的值</returns>
public static async Task<long> StringIncrementAsync(string key, long val = )
{
return await Do(db => db.StringIncrementAsync(key, val));
} /// <summary>
/// 为数字减少val
/// </summary>
/// <param name="key"></param>
/// <param name="val">可以为负</param>
/// <returns>减少后的值</returns>
public static async Task<long> StringDecrementAsync(string key, long val = )
{
return await Do(db => db.StringDecrementAsync(key, val));
} /// <summary>
/// 为数字增长val
/// </summary>
/// <param name="key"></param>
/// <param name="val">可以为负</param>
/// <returns>增长后的值</returns>
public static async Task<double> StringIncrementAsync(string key, double val = )
{
return await Do(db => db.StringIncrementAsync(key, val));
} /// <summary>
/// 为数字减少val
/// </summary>
/// <param name="key"></param>
/// <param name="val">可以为负</param>
/// <returns>减少后的值</returns>
public static async Task<double> StringDecrementAsync(string key, double val = )
{
return await Do(db => db.StringDecrementAsync(key, val));
} #endregion 异步方法 #endregion String #region Hash #region 同步方法 /// <summary>
/// 判断某个数据是否已经被缓存
/// </summary>
/// <param name="key"></param>
/// <param name="dataKey"></param>
/// <returns></returns>
public static bool HashExists(string key, string dataKey)
{
return Do(db => db.HashExists(key, dataKey));
} /// <summary>
/// 存储数据到hash表
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="key"></param>
/// <param name="dataKey"></param>
/// <param name="t"></param>
/// <returns></returns>
public static bool HashSet<T>(string key, string dataKey, T t)
{
return Do(db =>
{
string json = ConvertJson(t);
return db.HashSet(key, dataKey, json);
});
} /// <summary>
/// 移除hash中的某值
/// </summary>
/// <param name="key"></param>
/// <param name="dataKey"></param>
/// <returns></returns>
public static bool HashDel(string key, string dataKey)
{
return Do(db => db.HashDelete(key, dataKey));
} /// <summary>
/// 移除hash中的多个值
/// </summary>
/// <param name="key"></param>
/// <param name="dataKeys"></param>
/// <returns></returns>
public static long HashDel(string key, List<RedisValue> dataKeys)
{
return Do(db => db.HashDelete(key, dataKeys.ToArray()));
} /// <summary>
/// 从hash表获取数据
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="key"></param>
/// <param name="dataKey"></param>
/// <returns></returns>
public static T HashGet<T>(string key, string dataKey)
{
return Do(db =>
{
if (!HashExists(key, dataKey)) return default(T);
string value = db.HashGet(key, dataKey);
return ConvertObj<T>(value);
});
} /// <summary>
/// 为数字增长val
/// </summary>
/// <param name="key"></param>
/// <param name="dataKey"></param>
/// <param name="val">可以为负</param>
/// <returns>增长后的值</returns>
public static double HashIncrement(string key, string dataKey, double val = )
{
return Do(db => db.HashIncrement(key, dataKey, val));
} /// <summary>
/// 为数字减少val
/// </summary>
/// <param name="key"></param>
/// <param name="dataKey"></param>
/// <param name="val">可以为负</param>
/// <returns>减少后的值</returns>
public static double HashDecrement(string key, string dataKey, double val = )
{
return Do(db => db.HashDecrement(key, dataKey, val));
} /// <summary>
/// 获取hashkey所有Redis key
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="key"></param>
/// <returns></returns>
public static List<T> HashKeys<T>(string key)
{
return Do(db =>
{
RedisValue[] values = db.HashKeys(key);
return ConvetList<T>(values);
});
} /// <summary>
/// 获取hashkey所有Redis key
/// </summary>
/// <typeparam name="T"></typeparam>
/// <returns></returns>
public static List<T> HashGetAll<T>(string key)
{
var values = Do(db => db.HashGetAll(key));
return ConvetList<T>(values);
} #endregion 同步方法 #region 异步方法 /// <summary>
/// 判断某个数据是否已经被缓存
/// </summary>
/// <param name="key"></param>
/// <param name="dataKey"></param>
/// <returns></returns>
public static async Task<bool> HashExistsAsync(string key, string dataKey)
{
return await Do(db => db.HashExistsAsync(key, dataKey));
} /// <summary>
/// 存储数据到hash表
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="key"></param>
/// <param name="dataKey"></param>
/// <param name="t"></param>
/// <returns></returns>
public static async Task<bool> HashSetAsync<T>(string key, string dataKey, T t)
{
return await Do(db =>
{
string json = ConvertJson(t);
return db.HashSetAsync(key, dataKey, json);
});
} /// <summary>
/// 移除hash中的某值
/// </summary>
/// <param name="key"></param>
/// <param name="dataKey"></param>
/// <returns></returns>
public static async Task<bool> HashDelAsync(string key, string dataKey)
{
return await Do(db => db.HashDeleteAsync(key, dataKey));
} /// <summary>
/// 移除hash中的多个值
/// </summary>
/// <param name="key"></param>
/// <param name="dataKeys"></param>
/// <returns></returns>
public static async Task<long> HashDelAsync(string key, List<RedisValue> dataKeys)
{
return await Do(db => db.HashDeleteAsync(key, dataKeys.ToArray()));
} /// <summary>
/// 从hash表获取数据
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="key"></param>
/// <param name="dataKey"></param>
/// <returns></returns>
public static async Task<T> HashGeAsync<T>(string key, string dataKey)
{
string value = await Do(db => db.HashGetAsync(key, dataKey));
return ConvertObj<T>(value);
} /// <summary>
/// 为数字增长val
/// </summary>
/// <param name="key"></param>
/// <param name="dataKey"></param>
/// <param name="val">可以为负</param>
/// <returns>增长后的值</returns>
public static async Task<double> HashIncrementAsync(string key, string dataKey, double val = )
{
return await Do(db => db.HashIncrementAsync(key, dataKey, val));
} /// <summary>
/// 为数字减少val
/// </summary>
/// <param name="key"></param>
/// <param name="dataKey"></param>
/// <param name="val">可以为负</param>
/// <returns>减少后的值</returns>
public static async Task<long> HashDecrementAsync(string key, string dataKey, long val = )
{
return await Do(db => db.HashDecrementAsync(key, dataKey, val));
} /// <summary>
/// 为数字增长val
/// </summary>
/// <param name="key"></param>
/// <param name="dataKey"></param>
/// <param name="val">可以为负</param>
/// <returns>增长后的值</returns>
public static async Task<long> HashIncrementAsync(string key, string dataKey, long val = )
{
return await Do(db => db.HashIncrementAsync(key, dataKey, val));
} /// <summary>
/// 为数字减少val
/// </summary>
/// <param name="key"></param>
/// <param name="dataKey"></param>
/// <param name="val">可以为负</param>
/// <returns>减少后的值</returns>
public static async Task<double> HashDecrementAsync(string key, string dataKey, double val = )
{
return await Do(db => db.HashDecrementAsync(key, dataKey, val));
} /// <summary>
/// 获取hashkey所有Redis key
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="key"></param>
/// <returns></returns>
public static async Task<List<T>> HashKeysAsync<T>(string key)
{
RedisValue[] values = await Do(db => db.HashKeysAsync(key));
return ConvetList<T>(values);
} /// <summary>
/// 获取hashkey所有Redis key
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="key"></param>
/// <returns></returns>
public static async Task<List<T>> HashGetAllAsync<T>(string key)
{
var values = await Do(db => db.HashGetAllAsync(key));
return ConvetList<T>(values);
} #endregion 异步方法 #endregion Hash #region List #region 同步方法 /// <summary>
/// 移除指定ListId的内部List的值
/// </summary>
/// <param name="key"></param>
/// <param name="value"></param>
public static void ListRemove<T>(string key, T value)
{
Do(db => db.ListRemove(key, ConvertJson(value)));
} /// <summary>
/// 获取指定key的List
/// </summary>
/// <param name="key"></param>
/// <returns></returns>
public static List<T> ListRange<T>(string key)
{
return Do(redis =>
{
var values = redis.ListRange(key);
return ConvetList<T>(values);
});
} /// <summary>
/// 入队
/// </summary>
/// <param name="key"></param>
/// <param name="value"></param>
public static void ListRightPush<T>(string key, T value)
{
Do(db => db.ListRightPush(key, ConvertJson(value)));
} /// <summary>
/// 出队
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="key"></param>
/// <returns></returns>
public static T ListRightPop<T>(string key)
{
return Do(db =>
{
var value = db.ListRightPop(key);
return ConvertObj<T>(value);
});
} /// <summary>
/// 入栈
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="key"></param>
/// <param name="value"></param>
public static void ListLeftPush<T>(string key, T value)
{
Do(db => db.ListLeftPush(key, ConvertJson(value)));
} /// <summary>
/// 出栈
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="key"></param>
/// <returns></returns>
public static T ListLeftPop<T>(string key)
{
return Do(db =>
{
var value = db.ListLeftPop(key);
return ConvertObj<T>(value);
});
} /// <summary>
/// 获取集合中的数量
/// </summary>
/// <param name="key"></param>
/// <returns></returns>
public static long ListLength(string key)
{
return Do(redis => redis.ListLength(key));
} #endregion 同步方法 #region 异步方法 /// <summary>
/// 移除指定ListId的内部List的值
/// </summary>
/// <param name="key"></param>
/// <param name="value"></param>
public static async Task<long> ListRemoveAsync<T>(string key, T value)
{
return await Do(db => db.ListRemoveAsync(key, ConvertJson(value)));
} /// <summary>
/// 获取指定key的List
/// </summary>
/// <param name="key"></param>
/// <returns></returns>
public static async Task<List<T>> ListRangeAsync<T>(string key)
{
var values = await Do(redis => redis.ListRangeAsync(key));
return ConvetList<T>(values);
} /// <summary>
/// 入队
/// </summary>
/// <param name="key"></param>
/// <param name="value"></param>
public static async Task<long> ListRightPushAsync<T>(string key, T value)
{
return await Do(db => db.ListRightPushAsync(key, ConvertJson(value)));
} /// <summary>
/// 出队
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="key"></param>
/// <returns></returns>
public static async Task<T> ListRightPopAsync<T>(string key)
{
var value = await Do(db => db.ListRightPopAsync(key));
return ConvertObj<T>(value);
} /// <summary>
/// 入栈
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="key"></param>
/// <param name="value"></param>
public static async Task<long> ListLeftPushAsync<T>(string key, T value)
{
return await Do(db => db.ListLeftPushAsync(key, ConvertJson(value)));
} /// <summary>
/// 出栈
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="key"></param>
/// <returns></returns>
public static async Task<T> ListLeftPopAsync<T>(string key)
{
var value = await Do(db => db.ListLeftPopAsync(key));
return ConvertObj<T>(value);
} /// <summary>
/// 获取集合中的数量
/// </summary>
/// <param name="key"></param>
/// <returns></returns>
public static async Task<long> ListLengthAsync(string key)
{
return await Do(redis => redis.ListLengthAsync(key));
} #endregion 异步方法 #endregion List #region SortedSet 有序集合 #region 同步方法 /// <summary>
/// 添加
/// </summary>
/// <param name="key"></param>
/// <param name="value"></param>
/// <param name="score"></param>
public static bool SortedSetAdd<T>(string key, T value, double score)
{
return Do(redis => redis.SortedSetAdd(key, ConvertJson<T>(value), score));
} /// <summary>
/// 删除
/// </summary>
/// <param name="key"></param>
/// <param name="value"></param>
public static bool SortedSetRemove<T>(string key, T value)
{
return Do(redis => redis.SortedSetRemove(key, ConvertJson(value)));
} /// <summary>
/// 获取全部
/// </summary>
/// <param name="key"></param>
/// <returns></returns>
public static List<T> SortedSetRangeByRank<T>(string key)
{
return Do(redis =>
{
var values = redis.SortedSetRangeByRank(key);
return ConvetList<T>(values);
});
} /// <summary>
/// 获取集合中的数量
/// </summary>
/// <param name="key"></param>
/// <returns></returns>
public static long SortedSetLength(string key)
{
return Do(redis => redis.SortedSetLength(key));
} #endregion 同步方法 #region 异步方法 /// <summary>
/// 添加
/// </summary>
/// <param name="key"></param>
/// <param name="value"></param>
/// <param name="score"></param>
public static async Task<bool> SortedSetAddAsync<T>(string key, T value, double score)
{
return await Do(redis => redis.SortedSetAddAsync(key, ConvertJson<T>(value), score));
} /// <summary>
/// 删除
/// </summary>
/// <param name="key"></param>
/// <param name="value"></param>
public static async Task<bool> SortedSetRemoveAsync<T>(string key, T value)
{
return await Do(redis => redis.SortedSetRemoveAsync(key, ConvertJson(value)));
} /// <summary>
/// 获取全部
/// </summary>
/// <param name="key"></param>
/// <returns></returns>
public static async Task<List<T>> SortedSetRangeByRankAsync<T>(string key)
{
var values = await Do(redis => redis.SortedSetRangeByRankAsync(key));
return ConvetList<T>(values);
} /// <summary>
/// 获取集合中的数量
/// </summary>
/// <param name="key"></param>
/// <returns></returns>
public static async Task<long> SortedSetLengthAsync(string key)
{
return await Do(redis => redis.SortedSetLengthAsync(key));
} #endregion 异步方法 #endregion SortedSet 有序集合 #region key /// <summary>
/// 删除单个key
/// </summary>
/// <param name="key">redis key</param>
/// <returns>是否删除成功</returns>
public static bool KeyDel(string key)
{
return Do(db => db.KeyDelete(key));
} /// <summary>
/// 删除多个key
/// </summary>
/// <param name="keys">rediskey</param>
/// <returns>成功删除的个数</returns>
public static long KeyDel(List<string> keys)
{
return Do(db => db.KeyDelete(ConvertRedisKeys(keys)));
} /// <summary>
/// 判断key是否存储
/// </summary>
/// <param name="key">redis key</param>
/// <returns></returns>
public static bool KeyExists(string key)
{
return Do(db => db.KeyExists(key));
} /// <summary>
/// 设置Key的时间
/// </summary>
/// <param name="key">redis key</param>
/// <param name="secondTimeout"></param>
/// <returns></returns>
public static bool KeyExpire(string key, int secondTimeout)
{
return Do(db => db.KeyExpire(key, TimeSpan.FromSeconds(secondTimeout)));
} #endregion key #region 辅助方法 private static T Do<T>(Func<IDatabase, T> func)
{
try
{
var database = GetDatabase();
return func(database);
}
catch (Exception ex)
{
return default(T);
}
} private static string ConvertJson<T>(T value)
{
string result = value is string ? value.ToString() : JsonConvert.SerializeObject(value);
return result;
} private static T ConvertObj<T>(RedisValue value)
{
if (value.IsNullOrEmpty)
{
return default(T);
}
return JsonConvert.DeserializeObject<T>(value.ToString());
} private static List<T> ConvetList<T>(RedisValue[] values)
{
List<T> result = new List<T>();
foreach (var item in values)
{
var model = ConvertObj<T>(item);
result.Add(model);
}
return result;
} private static RedisKey[] ConvertRedisKeys(List<string> redisKeys)
{
return redisKeys.Select(redisKey => (RedisKey)redisKey).ToArray();
} private static List<T> ConvetList<T>(HashEntry[] values)
{
List<T> result = new List<T>();
foreach (var item in values)
{
if (!item.Value.IsNullOrEmpty)
{
var model = ConvertObj<T>(item.Value);
result.Add(model);
}
}
return result;
} #endregion 辅助方法 public static IBatch CreateBatch()
{
return GetDatabase().CreateBatch();
} public static ITransaction CreateTransaction()
{
return GetDatabase().CreateTransaction();
} //使用Keys *模糊匹配Key
public static List<string> GetMatchKeys(string key)
{
var result = (string[])GetDatabase().ScriptEvaluate(LuaScript.Prepare("return redis.call('KEYS',@keypattern)"), new { keypattern = key });
return result.ToList();
} //使用SCAN模糊匹配Key
public static List<string> ScanMatchKeys(string key)
{
var result = (string[])GetDatabase().ScriptEvaluate(
LuaScript.Prepare("local dbsize=redis.call('dbsize') local res=redis.call('scan',0,'match',KEYS[1],'count',dbsize) return res[2]"),
new RedisKey[] { key });
return result.ToList();
}
}
}
RedisHelper帮助类的更多相关文章
- Java类的继承与多态特性-入门笔记
相信对于继承和多态的概念性我就不在怎么解释啦!不管你是.Net还是Java面向对象编程都是比不缺少一堂课~~Net如此Java亦也有同样的思想成分包含其中. 继承,多态,封装是Java面向对象的3大特 ...
- Windows下Redis缓存服务器的使用 .NET StackExchange.Redis Redis Desktop Manager
Redis缓存服务器是一款key/value数据库,读110000次/s,写81000次/s,因为是内存操作所以速度飞快,常见用法是存用户token.短信验证码等 官网显示Redis本身并没有Wind ...
- Python 之路:Python操作 RabbitMQ、Redis、Memcache、SQLAlchemy
一.Memcached Memcached是一个高性能的分布式内存对象缓存系统,用于动态Web应用以减轻数据库负债.它通过在内存中缓存数据和对象来减少读取数据库的次数,从而提高动态.数据库驱动网站的速 ...
- .NET Core开发者的福音之玩转Redis的又一傻瓜式神器推荐
作者:依乐祝 原本链接:https://www.cnblogs.com/yilezhu/p/9947905.html 引子 为什么写这篇文章呢?因为.NET Core的生态越来越好了!之前玩转.net ...
- 【每日更新】【Redis学习】
5. Redis订阅和发布模式和Redis事务 -------------------Redis事务------------------- 1.概念: redis中的事务是一组命令的集合.事务 ...
- Windows下Redis缓存服务器的使用 .NET StackExchange.Redis Redis Desktop Manager 转发非原创
Windows下Redis缓存服务器的使用 .NET StackExchange.Redis Redis Desktop Manager Redis缓存服务器是一款key/value数据库,读11 ...
- [翻译] C# 8.0 新特性 Redis基本使用及百亿数据量中的使用技巧分享(附视频地址及观看指南) 【由浅至深】redis 实现发布订阅的几种方式 .NET Core开发者的福音之玩转Redis的又一傻瓜式神器推荐
[翻译] C# 8.0 新特性 2018-11-13 17:04 by Rwing, 1179 阅读, 24 评论, 收藏, 编辑 原文: Building C# 8.0[译注:原文主标题如此,但内容 ...
- C#版-Redis缓存服务器在Windows下的使用
Redis缓存服务器是一款key/value数据库,读110000次/s,写81000次/s,因为是内存操作所以速度飞快,常见用法是存用户token.短信验证码等 官网显示Redis本身并没有Wind ...
- Redis缓存相关
Redis缓存服务搭建及实现数据读写 RedisHelper帮助类 /// <summary> /// Redis 帮助类文件 /// </summary> public cl ...
随机推荐
- 三、Java多人博客系统-技术架构
多人博客系统1.0版本,架构和技术还是很简单和很传统的. 1.技术 前端:jsp.html.css.javascript.jquery.easyui.echarts 后端:spring mvc.Hib ...
- C#嵌入动态链接库到可执行文件
C#嵌入动态链接库到可执行文件 将需要被集成的程序集放在项目的lib文件夹中,引用路径从解决方案开始,以“.”连接. 如图(解决方案名称为莫非): 核心代码: AppDomain.CurrentDom ...
- 适配相关:viewpoint,@media,vw/vh,em/rem
从网易与淘宝的font-size思考前端设计稿与工作流: http://www.cnblogs.com/lyzg/p/4877277.html Rem布局的原理解析: https://yanhaiji ...
- CAN总线报文浅析
CAN的报文格式 在总线中传送的报文,每帧由7部分组成.CAN协议支持两种报文格式,其唯一的不同是标识符(ID)长度不同,标准格式为11位,扩展格式为29位. 在标准格式中,报文的起始位称为帧起始(S ...
- 51Nod--1247 可能的路径(gcd)
根据规则可知 假设 (a,b) 可以到达坐标(aa,bb) 那么 aa=a*x+b*y x y 必定有解 所以 我们只要求两个坐标的gcd看是否相等就好 #include<bits/stdc ...
- JMeter 的调式工具
任何的编程工具都会相应的调式工具,JMeter的调式 工具主要有五种: 1.查看结果树:含请求信息.响应信息等 2.HTTP 镜像服务器:HTTP Mirror Server用于查看请求信息 3.De ...
- python 实现进制转换(二进制转十进制)
摘自https://baike.baidu.com/item/%E5%8D%81%E8%BF%9B%E5%88%B6%E8%BD%AC%E4%BA%8C%E8%BF%9B%E5%88%B6 pytho ...
- usb驱动程序小结(六)
title: usb驱动程序小结 tags: linux date: 2018/12/20/ 17:59:51 toc: true --- usb驱动程序小结 linux中为usb驱动也提供了一套总线 ...
- css浮动(float)全方位案例解析
前言 浮动最早的使用是出自<img src="#" align="right" />,用于文本环绕图片的排版处理.当然也是一种常用的布局方式. fl ...
- TensorFlow资源整理
什么是TensorFlow? TensorFlow 是一个采用数据流图(data flow graphs),用于数值计算的开源软件库.节点(Nodes)在图中表示数学操作,图中的线(edges)则表示 ...