Documentation ¶
Index ¶
- type Client
- func (search *Client) Del(key string) (int64, error)
- func (search *Client) FlushDB() error
- func (search *Client) Get(key string) (string, error)
- func (search *Client) GetNextHeight() uint64
- func (search *Client) HGet(key, field string) (string, error)
- func (search *Client) HGetAll(key string) (map[string]string, error)
- func (search *Client) HSet(key, field string, value interface{}) (bool, error)
- func (search *Client) IndexDateToHeight(blockTime math.Timestamp, blockHeight uint64) (updateCount int, insertCount int, err error)
- func (search *Client) Inner() *redis.Client
- func (search *Client) Keys(pattern string) ([]string, error)
- func (search *Client) Ping() error
- func (search *Client) SAdd(key string, value string) (int64, error)
- func (search *Client) SScan(key string, cb func(value string) error) error
- func (search *Client) SearchDateRange(first, last string) (uint64, uint64, error)
- func (search *Client) Set(key string, value interface{}) error
- func (search *Client) SetNextHeight(height uint64) (err error)
- func (search *Client) ZAdd(key string, score float64, value string) (int64, error)
- func (search *Client) ZCard(key string) (int64, error)
- func (search *Client) ZRevRange(key string, start, stop int64) ([]string, error)
- func (search *Client) ZRevRangeByScore(key string, max float64, count int64) ([]string, error)
- func (search *Client) ZRevRank(key, searchValue string) (int64, error)
- func (search *Client) ZScan(key string, cb func(value string, score float64) error) error
- func (search *Client) ZUnionStore(key string, searchKeys []string) (int64, error)
- type DateRangeRequest
- type DateRangeResult
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client manages a redis.Client for use with indexing and searching within a node.
func NewClient ¶
NewClient is a factory method for Client. The address should contain ip and port with no "http://", e.g. "localhost:6379". Pass in a version number for your client. Start it at zero. If you later increment it, the client will wipe the database and require reindexing.
func (*Client) Get ¶
Get is a wrapper for redis GET. Returns empty string (not nil) if the key doesn't exist.
func (*Client) GetNextHeight ¶
GetNextHeight gets the high water mark (height) we've indexed up to, but not including it.
func (*Client) HSet ¶
HSet is a wrapper for redis HSET. Returns true for new fields, false if field already exists.
func (*Client) IndexDateToHeight ¶
func (search *Client) IndexDateToHeight( blockTime math.Timestamp, blockHeight uint64, ) (updateCount int, insertCount int, err error)
IndexDateToHeight will index all necessary date-to-height keys back in time to the latest one we've indexed, using the given date and height. Typically this function will only need to do work once every dateRangeInterval seconds. But if there are long periods of block inactivity, this function will fill in all missing date-to-height keys up to the given block time. The given block height must be > 0, which is guaranteed if it comes from Tendermint.
func (*Client) Inner ¶
Inner returns the internal bare client so that methods can be accessed without wrapping
func (*Client) SearchDateRange ¶
SearchDateRange returns the first and last block heights for the given ISO-3339 date range. The first is inclusive, the last is exclusive.
func (*Client) SetNextHeight ¶
SetNextHeight saves the given height in the database as a high water mark. Call this after you've indexed something at a given blockchain height. It's also acceptable to call this once after an initial scan. It will make the next scan-on-launch index blocks down to, and including, this height.
func (*Client) ZCard ¶
ZCard is a wrapper for redis ZCARD. It's like "ZCOUNT key -inf +inf" but is O(1).
func (*Client) ZRevRangeByScore ¶
ZRevRangeByScore is a wrapper for redis ZREVRANGEBYSCORE without returning scores. We use an exclusive range (-inf, max). The initial use-case for this was for returning all transactions in and before a given block height, and scores for transactions are floats with integer part being the height and fractional part holding the tx offset within the block. So, for example, to get all transactions on or before height 50, we'd use:
ZRevRangeByScore(key, 51.0, count)
This will include a transaction with score 50.999 (the 1000th tx in block 50). It will not include a transaction with score 51 (the first tx in block 51). See ndau/pkg/ndau/search/index.go for how we encode height-txoffset pairs in a float score. The count param can be used to limit the number of results. Zero means no limit.
type DateRangeRequest ¶
DateRangeRequest is used for passing date range query terms over endpoints.
func (*DateRangeRequest) Marshal ¶
func (request *DateRangeRequest) Marshal() string
Marshal the request.
func (*DateRangeRequest) Unmarshal ¶
func (request *DateRangeRequest) Unmarshal(requestString string) error
Unmarshal the request.
type DateRangeResult ¶
DateRangeResult is used for returning search results for the date range endpoint.
func (*DateRangeResult) Marshal ¶
func (result *DateRangeResult) Marshal() string
Marshal the result.
func (*DateRangeResult) Unmarshal ¶
func (result *DateRangeResult) Unmarshal(resultString string) error
Unmarshal the result.