项目作者: didier-wenzek

项目描述 :
OCaml bindings for kyoto cabinet DBM
高级语言: OCaml
项目地址: git://github.com/didier-wenzek/ocaml-kyotocabinet.git
创建时间: 2013-04-18T08:12:31Z
项目社区:https://github.com/didier-wenzek/ocaml-kyotocabinet

开源协议:GNU General Public License v3.0

下载


OCaml bindings for kyoto cabinet DBM

Pre-requisites

License

GNU General Public License.

Install

Using OPAM:

  1. $ opam install kyotocabinet

Or from source:

  1. $ make # use jbuilder
  2. $ make test
  3. $ make install

Documentation

The API is documented in lib/kyoto.mli

Basic

  1. #use "topfind";;
  2. #require "kyotocabinet";;
  3. (* create a database, here an in-memory tree database. *)
  4. let db = Kyoto.opendb "+" [Kyoto.OWRITER; Kyoto.OCREATE];;
  5. (* store records *)
  6. Kyoto.set db "foo" "hop";;
  7. Kyoto.set db "bar" "step";;
  8. Kyoto.set db "baz" "jump";;
  9. Kyoto.set db "baz2" "jump";;
  10. (* retrieve records *)
  11. Kyoto.get db "foo";;
  12. Kyoto.get db "xoxox";;
  13. (* update records *)
  14. Kyoto.set db "bar" "step2";;
  15. Kyoto.remove db "baz2";;
  16. (* fold the whole database *)
  17. Kyoto.fold db (fun n x -> n+1) 0;;
  18. (* use a cursor to iter over the database *)
  19. let cursor = Kyoto.cursor_open db;;
  20. Kyoto.cursor_next cursor;;
  21. Kyoto.cursor_next cursor;;
  22. Kyoto.cursor_next cursor;;
  23. Kyoto.cursor_next cursor;;
  24. Kyoto.cursor_close cursor;;
  25. (* close the database *)
  26. Kyoto.close db;;