本站源代码
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

62 linhas
1.8KB

  1. // package nodb is a high performance embedded NoSQL.
  2. //
  3. // nodb supports various data structure like kv, list, hash and zset like redis.
  4. //
  5. // Other features include binlog replication, data with a limited time-to-live.
  6. //
  7. // Usage
  8. //
  9. // First create a nodb instance before use:
  10. //
  11. // l := nodb.Open(cfg)
  12. //
  13. // cfg is a Config instance which contains configuration for nodb use,
  14. // like DataDir (root directory for nodb working to store data).
  15. //
  16. // After you create a nodb instance, you can select a DB to store you data:
  17. //
  18. // db, _ := l.Select(0)
  19. //
  20. // DB must be selected by a index, nodb supports only 16 databases, so the index range is [0-15].
  21. //
  22. // KV
  23. //
  24. // KV is the most basic nodb type like any other key-value database.
  25. //
  26. // err := db.Set(key, value)
  27. // value, err := db.Get(key)
  28. //
  29. // List
  30. //
  31. // List is simply lists of values, sorted by insertion order.
  32. // You can push or pop value on the list head (left) or tail (right).
  33. //
  34. // err := db.LPush(key, value1)
  35. // err := db.RPush(key, value2)
  36. // value1, err := db.LPop(key)
  37. // value2, err := db.RPop(key)
  38. //
  39. // Hash
  40. //
  41. // Hash is a map between fields and values.
  42. //
  43. // n, err := db.HSet(key, field1, value1)
  44. // n, err := db.HSet(key, field2, value2)
  45. // value1, err := db.HGet(key, field1)
  46. // value2, err := db.HGet(key, field2)
  47. //
  48. // ZSet
  49. //
  50. // ZSet is a sorted collections of values.
  51. // Every member of zset is associated with score, a int64 value which used to sort, from smallest to greatest score.
  52. // Members are unique, but score may be same.
  53. //
  54. // n, err := db.ZAdd(key, ScorePair{score1, member1}, ScorePair{score2, member2})
  55. // ay, err := db.ZRangeByScore(key, minScore, maxScore, 0, -1)
  56. //
  57. // Binlog
  58. //
  59. // nodb supports binlog, so you can sync binlog to another server for replication. If you want to open binlog support, set UseBinLog to true in config.
  60. //
  61. package nodb
上海开阖软件有限公司 沪ICP备12045867号-1