开发者

Library for maintaining on-disk cache [closed]

开发者 https://www.devze.com 2023-04-13 01:28 出处:网络
Closed. This question is seeking recommendations for books, tools, software libraries, and more. It does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed. This question is seeking recommendations for books, tools, software libraries, and more. It does not meet Stack Overflow guidelines. It is not currently accepting answers.

We don’t allow questions seeking recommendations for books, tools, 开发者_开发知识库software libraries, and more. You can edit the question so it can be answered with facts and citations.

Closed 6 years ago.

Improve this question

I'm looking for a library for C/C++/Obj-C to maintain on-disk cache for my objects.

  • There is large number of objects (tens of thousands) and each object is 100+Kb in size
  • Objects are constantly accessed/added, sometimes large group of objects is replaced

Currently I just store each object in separate file but I don't want to create so many files in the filesystem. Is there any library to work with such cache that will use one/several files instead?


You can make a collection (NSArray, NSSet, NSDictionary) with all your objects and use NSKeyedArchiver/NSKeyedUnarchiver to put that into a single file.

You can also use an SQLite database or CoreData, the advantage being that you wouldn't have to have everything loaded into memory at once if, you just pull objects out of it as needed. Especially if you have (tens of thousands * 100+Kb, which would never fit into memory anyway...).

You could also use C++ serialization libraries (although getting them to work with obj c objects would be tricky..., more recommended for C++ objects) like boost serialization/archive (can output binary, text, xml), again you could use collections (std::list, std::map ...) to store them all into one file.


I solved my problem using Tokyo Cabinet library. Works faster than using separate files for each object.

0

精彩评论

暂无评论...
验证码 换一张
取 消