Loading ...
Sorry, an error occurred while loading the content.

Caching interim results

Expand Messages
  • Romeyke, Andreas
    Hello, In a program we are producing interim results, and the results are stored to harddisk and loaded if needed. To effectively use it, we introduce a cache.
    Message 1 of 1 , Apr 14, 2011
    • 0 Attachment
      Hello,

      In a program we are producing interim results, and the results are
      stored to harddisk and loaded if needed. To effectively use it, we
      introduce a cache. At the moment the cache has place for 30 results and
      will be cleaned if a new result arrives.

      Here the signature of the caching module:

      type blob_t =
      String of string
      | Img of Img_types.img_t
      | Lbbox of (int * (int * int) * (Types.simplelayer_t * Types.bbox_t)
      list)
      | Segments of (Types.segment_t list)
      | Structures of (Types.structure_t list)

      type cache_t = (string, blob_t) Hashtbl.t
      val cache_outfile : (string, blob_t) Hashtbl.t -> string -> blob_t ->
      unit
      val find_infile : (string, 'a) Hashtbl.t -> string -> 'a
      val load_bmp : (string, blob_t) Hashtbl.t -> string -> Img_types.img_t
      val write_bmp :
      (string, blob_t) Hashtbl.t -> Img_types.img_t -> string -> unit
      val load_lbboxlst : (string, blob_t) Hashtbl.t -> string -> int * (int
      * int) * (Types.simplelayer_t * Types.bbox_t) list
      val store_lbboxlst : (string, blob_t) Hashtbl.t -> string -> int -> (int
      * int) -> (Types.simplelayer_t * Types.bbox_t) list -> unit
      val load_segments : (string, blob_t) Hashtbl.t -> string ->
      Types.segment_t list
      val store_segments : (string, blob_t) Hashtbl.t -> string ->
      Types.segment_t list -> unit
      val load_structures : (string, blob_t) Hashtbl.t -> string ->
      Types.structure_t list
      val store_structures : (string, blob_t) Hashtbl.t -> string ->
      Types.structure_t list -> unit

      As you can see, we have specialized load/store functions. The
      store-functions write the data to a given filename and the result will
      be stored in cache-object with its filename as key.

      The load-functions try to find the result in cache-object and if nout
      found, it loads from given file.

      The problem is, that we need a more sophisticated caching, this means,
      objects should be cached only if enough RAM is enable. If the free RAM
      will be limited, the cache should be freed.

      I was looking for module Weak, but I think it is hard to understand and
      how we could use this for our case is not very clear. I had also a look
      to the GC-module, but there is no way to answer the question if enough
      RAM is available.

      Could you point me to some hints? If you could a simple soultion it will
      be fine.

      Bye Andreas


      [Non-text portions of this message have been removed]
    Your message has been successfully submitted and would be delivered to recipients shortly.