本文整理汇总了Golang中github.com/cloudfoundry/hm9000/storeadapter.StoreAdapter.Get方法的典型用法代码示例。如果您正苦于以下问题:Golang StoreAdapter.Get方法的具体用法?Golang StoreAdapter.Get怎么用?Golang StoreAdapter.Get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/cloudfoundry/hm9000/storeadapter.StoreAdapter
的用法示例。
在下文中一共展示了StoreAdapter.Get方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1:
Ω(err).ShouldNot(HaveOccured())
store = NewStore(conf, etcdAdapter)
})
Describe("Bumping freshness", func() {
bumpingFreshness := func(key string, ttl uint64, bump func(store Store, timestamp time.Time) error) {
var timestamp time.Time
BeforeEach(func() {
timestamp = time.Now()
})
Context("when the key is missing", func() {
BeforeEach(func() {
_, err := etcdAdapter.Get(key)
Ω(err).Should(Equal(storeadapter.ErrorKeyNotFound))
err = bump(store, timestamp)
Ω(err).ShouldNot(HaveOccured())
})
It("should create the key with the current timestamp and a TTL", func() {
value, err := etcdAdapter.Get(key)
Ω(err).ShouldNot(HaveOccured())
var freshnessTimestamp models.FreshnessTimestamp
json.Unmarshal(value.Value, &freshnessTimestamp)
Ω(freshnessTimestamp.Timestamp).Should(Equal(timestamp.Unix()))