View Source filezcache (filezcache v2.2.1)

Filezcache api, insert, lookup, stream and delete cached files.

Summary

Functions

Save access time as a information in the datastore.

Append to existed stream.

Return checksum.

Return the directory for the storage of the cached files.

Delete data item for the storage.

Finish existed stream.

Insert binary value and options.

Insert file and options.

Insert temporary file and options.

Return the directory for the storage of the log/journal files.

Try to find monitor by Key.

Lookup datastore element by Key. Either returns the file in the filecache or a device pid to read from. The file is returned if the cache entry is complete, the device is returned if the cache entry is being written to. Read the device using file:read(Pid, Length).

Lookup datastore element by Pid or Key and options.

Lookup File by Key.

Lookup Pid and options.

Return data storade information.

Check existence of Key in the data storage.

Functions

-spec access(Key) -> Result when Key :: term(), Result :: ok.

Save access time as a information in the datastore.

-spec append_stream(Pid, Bin) -> Result when Pid :: pid(), Bin :: binary(), Result :: ok.

Append to existed stream.

-spec checksum(Filename) -> Result when Filename :: file:filename_all(), Result :: binary().

Return checksum.

-spec data_dir() -> Result when Result :: file:filename_all().

Return the directory for the storage of the cached files.

-spec delete(Key) -> Result
          when
              Key :: term(),
              Result :: ok | {error, Reason},
              Reason :: lockedlog_a | writing | active.

Delete data item for the storage.

-spec finish_stream(Pid) -> Result when Pid :: pid(), Result :: ok.

Finish existed stream.

-spec insert(Key, Bin) -> Result
          when
              Key :: term(),
              Bin :: binary(),
              Result :: {ok, Pid} | {error, Reason},
              Pid :: pid(),
              Reason :: term().

Equivalent to insert(Key, Bin, []).

Insert binary value.

-spec insert(Key, Bin, Opts) -> Result
          when
              Key :: term(),
              Bin :: binary(),
              Opts :: list(),
              Result :: {ok, Pid} | {error, Reason},
              Pid :: pid(),
              Reason :: term().

Insert binary value and options.

Link to this function

insert_file(Key, FilePath)

View Source
-spec insert_file(Key, FilePath) -> Result
               when
                   Key :: term(),
                   FilePath :: file:filename_all(),
                   Result :: {ok, Pid} | {error, Reason},
                   Pid :: pid(),
                   Reason :: term().

Equivalent to insert_file(Key, FilePath, []).

Insert file.

Link to this function

insert_file(Key, FilePath, Opts)

View Source
-spec insert_file(Key, FilePath, Opts) -> Result
               when
                   Key :: term(),
                   FilePath :: file:filename_all(),
                   Opts :: list(),
                   Result :: {ok, Pid} | {error, Reason},
                   Pid :: pid(),
                   Reason :: term().

Insert file and options.

-spec insert_stream(Key) -> Result
                 when
                     Key :: term(),
                     Result :: {ok, Pid} | {error, Reason},
                     Pid :: pid(),
                     Reason :: term().

Equivalent to insert_stream(Key, undefined, []).

Insert stream.

Link to this function

insert_stream(Key, FinalSize, Opts)

View Source
-spec insert_stream(Key, FinalSize, Opts) -> Result
                 when
                     Key :: term(),
                     FinalSize :: non_neg_integer() | undefined,
                     Opts :: list(),
                     Result :: {ok, Pid} | {error, Reason},
                     Pid :: pid(),
                     Reason :: term().

Insert stream.

Link to this function

insert_stream(Key, FinalSize, StreamFun, Opts)

View Source
-spec insert_stream(Key, FinalSize, StreamFun, Opts) -> Result
                 when
                     Key :: term(),
                     FinalSize :: non_neg_integer() | undefined,
                     StreamFun :: function(),
                     Opts :: list(),
                     Result :: {ok, Pid} | {error, Reason},
                     Pid :: pid(),
                     Reason :: term().

Insert stream.

Link to this function

insert_tmpfile(Key, FilePath)

View Source
-spec insert_tmpfile(Key, FilePath) -> Result
                  when
                      Key :: term(),
                      FilePath :: file:filename_all(),
                      Result :: {ok, Pid} | {error, Reason},
                      Pid :: pid(),
                      Reason :: term().

Equivalent to insert_tmpfile(Key, FilePath, []).

Insert temporary file.

Link to this function

insert_tmpfile(Key, FilePath, Opts)

View Source
-spec insert_tmpfile(Key, FilePath, Opts) -> Result
                  when
                      Key :: term(),
                      FilePath :: file:filename_all(),
                      Opts :: list(),
                      Result :: {ok, Pid} | {error, Reason},
                      Pid :: pid(),
                      Reason :: term().

Insert temporary file and options.

-spec journal_dir() -> Result when Result :: file:filename_all().

Return the directory for the storage of the log/journal files.

-spec locate_monitor(Key) -> Result
                  when
                      Key :: term(),
                      Result ::
                          {ok, {file, FileSize, Filename}} | {ok, {pid, pid()}} | {error, Reason},
                      FileSize :: non_neg_integer(),
                      Filename :: file:filename_all(),
                      Reason :: enoent.

Try to find monitor by Key.

-spec lookup(Key) -> Result
          when
              Key :: term(),
              Result :: {ok, {file, FileSize, Filename}} | {ok, {device, Pid}} | {error, term()},
              FileSize :: non_neg_integer(),
              Filename :: file:filename_all(),
              Pid :: file:io_device().

Lookup datastore element by Key. Either returns the file in the filecache or a device pid to read from. The file is returned if the cache entry is complete, the device is returned if the cache entry is being written to. Read the device using file:read(Pid, Length).

-spec lookup(PidOrKey, Opts) -> Result when PidOrKey :: pid() | term(), Opts :: list(), Result :: term().

Lookup datastore element by Pid or Key and options.

-spec lookup_file(Key) -> Result
               when
                   Key :: term(),
                   Result :: {ok, {file, FileSize, Filename}} | {error, Reason},
                   FileSize :: non_neg_integer(),
                   Filename :: file:filename_all(),
                   Reason :: enoent.

Lookup File by Key.

Link to this function

lookup_file(PidOrKey, Opts)

View Source
-spec lookup_file(PidOrKey, Opts) -> Result
               when
                   PidOrKey :: pid() | term(),
                   Opts :: list(),
                   Result :: {ok, {file, FileSize, Filename}} | {error, Reason},
                   FileSize :: non_neg_integer(),
                   Filename :: file:filename_all(),
                   Reason :: enoent.

Lookup Pid and options.

-spec stats() -> Stats
         when
             Stats ::
                 #{bytes := non_neg_integer(),
                   max_bytes := non_neg_integer(),
                   processes := non_neg_integer(),
                   entries := non_neg_integer(),
                   referrers := non_neg_integer(),
                   gc_candidate_pool := list(),
                   insert_count := non_neg_integer(),
                   delete_count := non_neg_integer(),
                   hit_count := non_neg_integer(),
                   miss_count := non_neg_integer(),
                   evict_count := non_neg_integer()}.

Return data storade information.

-spec where(Key) -> Result when Key :: term(), Result :: Pid | undefined, Pid :: pid().

Check existence of Key in the data storage.