-
-
Notifications
You must be signed in to change notification settings - Fork 413
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Apprise to Support Persistent Storage #749
Labels
Comments
Closed
Issue resolved |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
💡 The Idea
Apprise needs to support persistent storage.
It requires a nice library like the Attachments, and Configuration that the Plugin library can readily/easily access.
The persistent storage should be a switch that defaults to being off, but can be toggled to
on
from theAppriseAsset()
object (storage_mode="memory"
by default)The Persistent storage would be adapted by the
NotifyBase
object making it accessible in every plugins environment without the need of an extra import.The CLI tool has Persistent Storage enabled by default.
The CLI tool provides an extra
--storage-mode
which can be set toauto
(default),flush
, andmemory
.auto
: This is the default option and pesistent storage is used when applicable (only the plugins that require it take advantage of local cache made available to them).flush
: Similar toauto
except that any changes made are immediately flushed to disk. This mode creates a higher i/o but enforces the content on disk is the latest.memory
: Effectively turns off Persistent storage. No plugins are allowed to write to disk. This is exactly the way Apprise was prior ro the Persistent Storage feature.To remove all accumulated persistent storage generated through the CLI tool, you can run the following:
You can compliment this call by providing URL IDs and/or
--tag
(or-g
) values to focus on only cleaning specific persistently cached data. For example:# Assuming we want to target the URL ID of abc123xy apprise storage clean abc123xy
You can also clear cache based on tag references:
# Assuming we want to target the URL(s) associated with the tag 'family' apprise storage clean --tag family
The current version of Apprise would be written to disk in the persisent storage space (if enabled by the AppriseAsset() object). Subsequent runs of Apprise would then check this version and compare it to the current one running. If they differ, all persistent data would be reset/cleared and the version file updated.
Today the use cases for Persistent Storage are:
@user
and get it's ID (An extra GET Request). From there it hangs onto it in memory for future notifications. With Persistent storage, this can be written to disk and save future hits even when the program is restarted from scratch. This would be a noticeable performance increasevisibility=direct
) requires an additional hit to the Mastodon API to retrieve our information. Caching this information would be 1 less URL hit later on.#640 would tie back to this enhancement as well.
Plugin Logic
Persistent Store Details
I was thinking of the following; but am open for discussion:
Use an sqlite database, or perhaps just convert content to JSON and write straight to disk (+ zip) might be easier.
sha1()
of Apprise URL would id the directory/namespace it all content would write to. e.g:549f6c03f0fb0095e02a0e68deb1b49e149f29d6
set()
,get()
, andclear()
would write to a file calleddb
stored in the namespace;- e.g:
%{namespace}/db
would be something like:549f6c03f0fb0095e02a0e68deb1b49e149f29d6/db
self.persistent.open()
would be written to the same%{namespace}
but would reside in a sub directory calledpersist
.- e.g:
%{namespace}/persist/
would be something like:549f6c03f0fb0095e02a0e68deb1b49e149f29d6/persist/
Namespaces would all reside in the following path (additionally prefixed with a
%{schema}
such asdiscord
ortwitter
, etc to make it easier to further troubleshoot or allow users to clear specific persisten directories..~/.apprise/persist/%{schema}/%{namespace}/
(Linux)~/.config/apprise/persist/%{schema}/%{namespace}/
(Linux)%APPDATA%/Apprise/persist/%{schema}/%{namespace}/
(Windows)%LOCALAPPDATA%/Apprise/persist/%{schema}/%{namespace}/
(Windows)the
sha1()
generated namespace can be overridden by the Notify() object itself through a definednamespace(self)
function. Users can further look at the variables provided (ignoring extra kwargs that should not change the variance of thepersist
directory) and return a more specific/focused (and re-usable) location. Otherwise the parentNotifyBase()
will return the generalsha1(self.url())
one.🔨 Breaking Feature
The functions/integration should be able to be implemented in such a way there would be no breaking change.
This may introduce plugins that depend on persistent storage to work and would have to be reported disabled via the
Apprise.details()
when the flag is off.The text was updated successfully, but these errors were encountered: