Documentation ¶
Index ¶
- Variables
- type Config
- type DocSet
- type Document
- type IDSet
- type Index
- func (i *Index) Get(id string) (doc *Document, err error)
- func (i *Index) GetAll() (docs *DocSet, err error)
- func (i *Index) GetManifest(id string) (*Manifest, error)
- func (i *Index) Keys() IDSet
- func (i *Index) LRUKeys() IDSet
- func (i *Index) LoadDocuments(docIDs IDSet, updatedAfter Timestamp) (*DocSet, error)
- func (i *Index) Query(manifestID string, updatedAfter Timestamp) (*DocSet, error)
- func (i *Index) SoftDelete(ids IDSet) (*DocSet, error)
- func (i *Index) Update(docs *DocSet) (*DocSet, error)
- type IndexManager
- type MCache
- func (m *MCache) CreateIndex(id string) (*Index, error)
- func (m *MCache) Get(indexID string, docID string) (*Document, error)
- func (m *MCache) GetAll(indexID string) (*DocSet, error)
- func (m *MCache) GetIndex(id string) *Index
- func (m *MCache) Keys(indexID string) (IDSet, error)
- func (m *MCache) Query(indexID string, manifestID string, updatedAfter Timestamp) (*DocSet, error)
- func (m *MCache) SoftDelete(indexID string, ids IDSet) (*DocSet, error)
- func (m *MCache) Update(indexID string, docs *DocSet) (*DocSet, error)
- type Manifest
- type SetEntry
- type Timestamp
Constants ¶
This section is empty.
Variables ¶
var DefaultConfig = Config{
LRUCacheSize: 10000,
MaxIndexCount: 100000,
MaxIndexSize: 100000,
DataDir: "./.mcache",
Host: "localhost",
Port: "1337",
}
DefaultConfig describes a default configuration for MCache
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct { LRUCacheSize int MaxIndexCount int MaxIndexSize int DataDir string Host string Port string }
Config describes the configuration of an MCache instance
type DocSet ¶
type DocSet struct { Docs map[string]Document `json:"docs"` Start Timestamp `json:"start"` End Timestamp `json:"end"` }
DocSet is a map of document IDs to documents
type Document ¶
type Document struct { ID string `json:"id"` UpdatedAt Timestamp `json:"updatedAt"` Body []byte `json:"body"` Deleted bool `json:"deleted"` }
Document is a resource that can be accessed by users
type Index ¶
type Index struct { ID string `json:"id"` // contains filtered or unexported fields }
Index represents a collection of documents managed by the cache
func (*Index) GetManifest ¶
GetManifest returns a manifest document
func (*Index) LoadDocuments ¶
LoadDocuments will, for a given set of document IDs, query the LRU cache for the latest matching versions and fetch the rest from the store
func (*Index) Query ¶
Query returns any documents matching the manifest with the given id that were updated after the given timestamp
func (*Index) SoftDelete ¶
SoftDelete updates the index documents with a tombstone value
type IndexManager ¶
type IndexManager struct { *mutable.RW Indexes map[string]*Index // contains filtered or unexported fields }
IndexManager manages a collection of Indexes
func NewIndexManager ¶
func NewIndexManager(config Config) *IndexManager
NewIndexManager initializes an IndexManager at the given path
func (*IndexManager) GetIndex ¶
func (m *IndexManager) GetIndex(id string) *Index
GetIndex returns the index with the given id, or nil if one is not found
func (*IndexManager) Open ¶
func (m *IndexManager) Open(id string) (*Index, error)
Open creates or returns an index with the given id
func (*IndexManager) Scan ¶
func (m *IndexManager) Scan() error
Scan will open any indexes whose data files are in the configured directory
type MCache ¶
type MCache struct { Config // contains filtered or unexported fields }
MCache is an HTTP-accessible object cache
func (*MCache) CreateIndex ¶
CreateIndex creates a new index with the given ID
func (*MCache) Query ¶
Query gets all index documents matching a given manifest that were updated after a given timestamp
func (*MCache) SoftDelete ¶
SoftDelete overwrites documents in the given index with the given IDs with tombstone values
type Manifest ¶
type Manifest struct { ID string `json:"id"` UpdatedAt int64 `json:"updatedAt"` DocumentIDs IDSet `json:"documentIDs"` }
Manifest is a user's set of accessible document IDs
func DecodeManifest ¶
DecodeManifest returns a Manifest that is stored in a Document