Event replay and cleanup
This commit is contained in:
parent
2560410820
commit
97bf66c191
8 changed files with 447 additions and 39 deletions
|
|
@ -263,6 +263,11 @@ func NewDocumentBuffer(
|
|||
* If cache is full oldest document is written to backing writer.
|
||||
*/
|
||||
func (b *DocBuf) Push(doc string) error {
|
||||
if b.cacheSize == 0 {
|
||||
b.writeToBackingStore(doc)
|
||||
return nil
|
||||
}
|
||||
|
||||
if len(b.cache) >= b.cacheSize {
|
||||
if err := b.demote(); err != nil {
|
||||
return err
|
||||
|
|
@ -280,6 +285,14 @@ func (b *DocBuf) Push(doc string) error {
|
|||
* out of the backing ReaderWriter.
|
||||
*/
|
||||
func (b *DocBuf) Pop() (string, error) {
|
||||
if b.cacheSize == 0 {
|
||||
d, e := b.readDocumentsFromDisk(1, true, false)
|
||||
if len(d) > 0 {
|
||||
return d[0], e
|
||||
}
|
||||
return "", e
|
||||
}
|
||||
|
||||
if len(b.cache) < 1 {
|
||||
if err := b.promote(true); err != nil {
|
||||
return "", err
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue