Add some doc/spec

This commit is contained in:
Kresten Krab Thorup 2012-05-11 12:30:20 +02:00
parent fbda7af576
commit 61720065d9
3 changed files with 13 additions and 7 deletions

View file

@ -41,6 +41,11 @@ Put these values in your `app.config` in the `hanoidb` section
%% %%
{compress, none | gzip}, {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 %% Sync strategy `none' only syncs every time the
%% nursery runs full, which is currently hard coded %% nursery runs full, which is currently hard coded
%% to be evert 256 inserts or deletes. %% to be evert 256 inserts or deletes.

10
TODO
View file

@ -1,18 +1,12 @@
* Phase 1: Minimum viable product (in order of priority) * Phase 1: Minimum viable product (in order of priority)
* lager; check for uses of lager:error/2 * lager; check for uses of lager:error/2
* configurable TOP_LEVEL size * 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 * test new snappy compression support
* support for time based expiry, merge should eliminate expired data
* status and statistics * status and statistics
* for each level {#merges, {merge-time-min, max, average}} * for each level {#merges, {merge-time-min, max, average}}
* add @doc strings and and -spec's * add @doc strings and and -spec's
* check to make sure every error returns with a reason {error, Reason} * check to make sure every error returns with a reason {error, Reason}
* clean up names, btree_range -> key_range, etc.
* Phase 2: Production Ready * Phase 2: Production Ready
* dual-nursery * dual-nursery
@ -20,6 +14,10 @@
* {cache, bytes(), name} share max(bytes) cache named 'name' via etc * {cache, bytes(), name} share max(bytes) cache named 'name' via etc
* snapshot entire database (fresh directory w/ hard links to all files) * snapshot entire database (fresh directory w/ hard links to all files)
* persist merge progress (to speed up re-opening a HanoiDB) * 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 * Phase 3: Wish List
* add truncate/1 - quickly truncates a database to 0 items * add truncate/1 - quickly truncates a database to 0 items

View file

@ -221,11 +221,14 @@ decode_kv_data(<<?TAG_TRANSACT, Rest/binary>>) ->
%%%%%%% %%%%%%%
%% Return number of seconds since 1970 %% @doc Return number of seconds since 1970
-spec tstamp() -> pos_integer().
tstamp() -> tstamp() ->
{Mega, Sec, _Micro} = os:timestamp(), {Mega, Sec, _Micro} = os:timestamp(),
(Mega * 1000000) + Sec. (Mega * 1000000) + Sec.
%% @doc Return time when values expire (i.e. Now - ExpirySecs), or 0.
-spec expiry_time([_]) -> pos_integer().
expiry_time(Opts) -> expiry_time(Opts) ->
ExpirySecs = hanoidb:get_opt(expiry_secs, Opts), ExpirySecs = hanoidb:get_opt(expiry_secs, Opts),
case ExpirySecs > 0 of case ExpirySecs > 0 of