StackExchange.Redis의 String 유형 예

12903 단어
String 유형은 간단합니다. 예시적으로 설명하지 않겠습니다. 여기에는 Helper 클래스만 붙입니다. /// /// key /// /// /// /// public bool KeyExists(string key, int db = -1) { try { _db = GetDatabase(db); return KeyExists(key); } catch (Exception) { throw; } } /// /// key /// /// /// public bool Remove(string key, int db = -1) { try { if ((object)key == null) return false; _db = GetDatabase(db); return KeyDelete(key); } catch (Exception ex) { _log.Fatal(" :{0} :{1}", key, ex.Message); throw; } } /// /// /// /// /// /// /// /// public bool Set(string key, T value, TimeSpan span, int db = -1) { try { if ((object)key == null || value == null) return false; _db = GetDatabase(db); if (value != null && (object)value is string) { return StringSet(key, value.ToString(), span); } return StringSet(key, value, span); } catch (Exception ex) { _log.Fatal("{0}key value:{1} , :{2}", key, value, ex.Message); throw; } } /// /// /// /// /// /// public T Get(string key, int db = -1) { try { _db = GetDatabase(db); return StringGet(key); } catch (Exception) { throw; } } /// /// /// /// /// public string Get(string key, int db = -1) { try { _db = GetDatabase(db); return StringGet(key); } catch (Exception) { throw; } } /// /// /// /// /// /// /// public long Increment(string key, TimeSpan span, int db = -1) { try { _db = GetDatabase(db); var result = this.StringIncr(key); // this.KeyExpire(key, span); return result; } catch (Exception) { throw; } } /// /// /// /// /// /// /// public long Decrement(string key, TimeSpan span, int db = -1) { try { _db = GetDatabase(db); var result = this.StringDecr(key); // this.KeyExpire(key, span); return result; } catch (Exception) { throw; } }

좋은 웹페이지 즐겨찾기