Writing a key-value store

前端 未结 7 1145
梦谈多话
梦谈多话 2021-02-04 08:12

I am looking to write a Key/value store (probably in python) mostly just for experience, and because it\'s something I think that is a very useful product. I have a couple of qu

7条回答
  •  情话喂你
    2021-02-04 09:09

    It all depends on the level of complexity you want to dive into. Starting with a simple Python dict serialized to a file in a myriad of possible ways (of which pickle is probably the simplest), you can go as far as implementing a complete database system.

    Look up redis - it's a key/value store written in C and operating as a server "DB". It has some good documentation and easy to read code, so you can borrow ideas for your Python implementation.

    To go even farther, you can read about B-trees.

    For your specific questions: above some DB size, you can never keep it all in memory, so you need some robust way of loading data from disk. Also consider whether the store is single-client or multi-client. This has serious consequences for its implementation.

提交回复
热议问题