Company
Date Published
Author
Trond Norbye, Senior Developer, Couchbase
Word count
732
Language
English
Hacker News points
None

Summary

In the blog post, the author delves into the memory allocation model within the memcached engine interface, explaining how memory management is divided between the memcached core and the engine. The core is responsible for allocating memory for connections, while the engine handles memory for item tracking, with the core accessing engine-managed memory when storing new items. The post illustrates how to implement an allocate function within the engine, detailing the creation of a data structure for storing item information, including keys, data, and metadata such as expiration time and flags. The allocate function is responsible for memory allocation, error handling, and data copying, while the get_item_info function is highlighted for its role in providing the core with necessary information about item storage, preparing for future support of scattered IO. The post concludes by touching on the storage process, where data moved over the network is stored in the engine.