本文整理匯總了Golang中github.com/encryptio/slime/internal/store.Store.Stat方法的典型用法代碼示例。如果您正苦於以下問題:Golang Store.Stat方法的具體用法?Golang Store.Stat怎麽用?Golang Store.Stat使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/encryptio/slime/internal/store.Store
的用法示例。
在下文中一共展示了Store.Stat方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: ShouldStatMiss
func ShouldStatMiss(t testing.TB, s store.Store, key string) {
st, err := s.Stat(key, nil)
if err != store.ErrNotFound {
t.Errorf("Stat(%#v) returned (%v, %v), but wanted %v",
key, st, err, store.ErrNotFound)
}
}
示例2: ShouldStatNoTime
func ShouldStatNoTime(t testing.TB, s store.Store, key string, stat store.Stat) {
st, err := s.Stat(key, nil)
if err != nil {
t.Errorf("Stat(%#v) returned unexpected error %v", key, err)
return
}
stat.WriteTime = st.WriteTime
if st != stat {
t.Errorf("Stat(%#v) = %#v, but wanted %#v", key, st, stat)
}
}
示例3: TestStoreWriteTime
func TestStoreWriteTime(t *testing.T, s store.Store) {
t.Logf("TestStoreWriteTime()")
ShouldCAS(t, s, "key", store.AnyV, store.DataV([]byte("one")))
now := time.Now().Unix()
st, err := s.Stat("key", nil)
if err != nil {
t.Fatalf("Couldn't stat key: %v", err)
}
diff := st.WriteTime - now
if diff < 0 {
diff = -diff
}
if diff > 2 {
t.Fatalf("Store returned timestamp %v, but wanted %v", st.WriteTime, now)
}
ShouldCAS(t, s, "key", store.AnyV, store.MissingV)
}