Documentation ¶
Overview ¶
Key generation and related methods relevant to any storage backend.
Index ¶
Constants ¶
const ( MASK_56 uint64 = 0xffffffffffffff CHECKSUM_MASK uint64 = 127 << 56 )
Variables ¶
This section is empty.
Functions ¶
func Key ¶
func Key(url URLWithHostname) uint64
Produces a 63 bit uint contained in a uint64 (SQLite cannot accept uint64 with high bit set as a primary key) [Bit 63] Always 0 [Bits 62-56] A 7 bit checksum based on the domain name [Bits 55-0] A 56 bit hash of the URL (reduced from a 64 bit fnv1a hash)
Types ¶
type URLDataStore ¶ added in v0.8.5
type URLDataStore struct {
// contains filtered or unexported fields
}
TODO: Stop embedding the database handle this way; the URLDataStore is currently opening and closing the database connection (via this interface), which prevents other entities from using the same connection.
func NewURLDataStore ¶ added in v0.8.5
func NewURLDataStore(dbh *database.DBHandle) *URLDataStore
func (*URLDataStore) Clear ¶ added in v0.8.5
func (s *URLDataStore) Clear() error
Clear will delete all url content from the database
func (*URLDataStore) Database ¶ added in v0.8.5
func (s *URLDataStore) Database() *database.DBHandle
func (*URLDataStore) Delete ¶ added in v0.8.5
func (s *URLDataStore) Delete(url *nurl.URL) (bool, error)
Delete will only delete a url that matches the canonical URL. TODO: Evaluate desired behavior here TODO: Not accounting for lookup keys NB: TTL management is handled by maintenance routines
func (URLDataStore) Fetch ¶ added in v0.8.5
Fetch will return the stored data for requested URL, or nil if not found.
The returned result _may_ come from a different URL than the requested URL, if we've seen the passed URL before AND the page reported it's canonical url as being different than the requested URL.
In that case, the canonical version of the content will be returned, if we have it.
func (*URLDataStore) Save ¶ added in v0.8.5
func (s *URLDataStore) Save(uptr *resource.WebPage) (uint64, error)
Save the data for a URL. Will overwrite data where the URL is the same. Save() will use the canonical url of the passed resource both for the key and for the url field in the stored data. It will also store an id map entry for the requested URL, back to the canonical URL. This mapping will also be stored in cases where the two urls are the same. Returns a key for the stored URL (which you actually can't use for anything, so this interface may change)
type URLWithHostname ¶
net.URL and URLString both implement this interface, which is needed to generate a key for the URL.