Monorepo for Tangled tangled.org
2

Configure Feed

Select the types of activity you want to include in your feed.

1package cursor 2 3import ( 4 "context" 5 "fmt" 6 "strconv" 7 8 "tangled.org/core/appview/cache" 9) 10 11const ( 12 cursorKey = "cursor:%s" 13) 14 15type RedisStore struct { 16 rdb *cache.Cache 17} 18 19func NewRedisCursorStore(cache *cache.Cache) RedisStore { 20 return RedisStore{ 21 rdb: cache, 22 } 23} 24 25func (r *RedisStore) Set(key string, cursor int64) { 26 k := fmt.Sprintf(cursorKey, key) 27 r.rdb.Set(context.Background(), k, cursor, 0) 28} 29 30func (r *RedisStore) Get(key string) (cursor int64) { 31 k := fmt.Sprintf(cursorKey, key) 32 val, err := r.rdb.Get(context.Background(), k).Result() 33 if err != nil { 34 return 0 35 } 36 parsed, err := strconv.ParseInt(val, 10, 64) 37 if err != nil { 38 return 0 39 } 40 return parsed 41}