diff --git a/README.md b/README.md index 7a90855..ba09317 100644 --- a/README.md +++ b/README.md @@ -40,6 +40,11 @@ Put these values in your `app.config` in the `hanoidb` section %% Enable/disable on-disk compression. %% {compress, none | gzip}, + + %% Expire (automatically delete) entries after N seconds. + %% When this value is 0 (zero), entries never expire. + %% + {expiry_secs, 0}, %% Sync strategy `none' only syncs every time the %% nursery runs full, which is currently hard coded diff --git a/TODO b/TODO index 9c2ad86..87485de 100644 --- a/TODO +++ b/TODO @@ -1,18 +1,12 @@ * Phase 1: Minimum viable product (in order of priority) * lager; check for uses of lager:error/2 * configurable TOP_LEVEL size - * support for future file format changes - * Define a standard struct which is the metadata added at the end of the - file, e.g. [btree-nodes] [meta-data] [offset of meta-data]. This is written - in hanoi_writer:flush_nodes, and read in hanoi_reader:open2. * test new snappy compression support - * support for time based expiry, merge should eliminate expired data * status and statistics * for each level {#merges, {merge-time-min, max, average}} * add @doc strings and and -spec's * check to make sure every error returns with a reason {error, Reason} - * clean up names, btree_range -> key_range, etc. * Phase 2: Production Ready * dual-nursery @@ -20,6 +14,10 @@ * {cache, bytes(), name} share max(bytes) cache named 'name' via etc * snapshot entire database (fresh directory w/ hard links to all files) * persist merge progress (to speed up re-opening a HanoiDB) + * support for future file format changes + * Define a standard struct which is the metadata added at the end of the + file, e.g. [btree-nodes] [meta-data] [offset of meta-data]. This is written + in hanoi_writer:flush_nodes, and read in hanoi_reader:open2. * Phase 3: Wish List * add truncate/1 - quickly truncates a database to 0 items diff --git a/src/hanoidb_util.erl b/src/hanoidb_util.erl index adf826b..256aec8 100644 --- a/src/hanoidb_util.erl +++ b/src/hanoidb_util.erl @@ -221,11 +221,14 @@ decode_kv_data(<>) -> %%%%%%% -%% Return number of seconds since 1970 +%% @doc Return number of seconds since 1970 +-spec tstamp() -> pos_integer(). tstamp() -> {Mega, Sec, _Micro} = os:timestamp(), (Mega * 1000000) + Sec. +%% @doc Return time when values expire (i.e. Now - ExpirySecs), or 0. +-spec expiry_time([_]) -> pos_integer(). expiry_time(Opts) -> ExpirySecs = hanoidb:get_opt(expiry_secs, Opts), case ExpirySecs > 0 of