store: support in-memory database

For testing, this is faster / and doesn't pollute the file system.
This commit is contained in:
Dirk-Jan C. Binnema
2021-02-16 19:32:15 +02:00
parent 98a742e5e5
commit 98abcf8e84
3 changed files with 67 additions and 11 deletions

View File

@ -1,5 +1,5 @@
/*
** Copyright (C) 2020 Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
** Copyright (C) 2021 Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
**
** This program is free software; you can redistribute it and/or modify it
** under the terms of the GNU General Public License as published by the
@ -69,6 +69,16 @@ public:
Store (const std::string& path, const std::string& maildir,
const StringVec& personal_addresses, const Config& conf);
/**
* Construct an in-memory, writeable store for testing
*
* @param maildir maildir to use for this store
* @param personal_addresses addresses that should be recognized as
* 'personal' for identifying personal messages.
*/
Store (const std::string& maildir,
const StringVec& personal_addresses, const Config& conf);
/**
* DTOR
*/
@ -81,6 +91,7 @@ public:
bool read_only; /**< Is the database opened read-only? */
size_t batch_size; /**< Maximum database transaction batch size */
bool in_memory; /**< Is this an in-memory database (for testing)?*/
std::string root_maildir; /**< Absolute path to the top-level maildir */
@ -117,7 +128,6 @@ public:
*/
Xapian::WritableDatabase& writable_database();
/**
* Get the Indexer associated with this store. It is an error to call
* this on a read-only store.