/// <summary> /// 获取文档并重置到期时提供的给定值。 /// </summary> /// <typeparam name="T"></typeparam> /// <param name="bucket"></param> /// <param name="key"></param> /// <param name="expiration"></param> /// <returns></returns> public T GetAndTouch <T>(DataBucketEnum bucket, string key, TimeSpan expiration) { var bucketName = bucket.ToString(); var bucketOperator = GetBucketOperator(bucketName); var result = bucketOperator.GetAndTouch <T>(key, expiration); return(result); }
/// <summary> /// 移除缓存(键不存在,也是删除成功) /// </summary> /// <param name="bucket">存放在哪个桶里</param> /// <param name="key">键名</param> /// <returns>True:成功,False:失败</returns> public bool Remove(DataBucketEnum bucket, string key) { var bucketName = bucket.ToString(); var bucketOperator = GetBucketOperator(bucketName); if (bucketOperator == null || string.IsNullOrEmpty(key)) { return(false); } return(bucketOperator.Remove(key)); }
/// <summary> /// 获取缓存 /// </summary> /// <typeparam name="T">缓存类型</typeparam> /// <param name="bucket">存放在哪个桶里</param> /// <param name="key">键名</param> /// <returns>缓存对象,如果没有,则返回null.</returns> public T Get <T>(DataBucketEnum bucket, string key) { var bucketName = bucket.ToString(); var bucketOperator = GetBucketOperator(bucketName); if (bucketOperator == null || string.IsNullOrEmpty(key)) { return(default(T)); } return(bucketOperator.Get <T>(key)); }