The new Redis module system is an exciting new innovation for Redis announced by Salvatore Sanfilippo at Redisconf in May. Redis modules give you the ability to extend Redis by loading dynamic libraries into it, creating new commands that operate on different data types or perform functions that Redis wasn’t designed for, including full text search, graph operations, SQL support, and more. Dvir Volk explains how the Redis module system was designed and how developers can take advantage of the power of Redis to create new commands and different data types.
To extend Redis properly, a module has to have access to Redis’s internal API. But directly exporting the Redis core functions to modules creates huge problems: the module starts to depend on the internal details of Redis. If the Redis core evolves, the module needs to be rewritten. This creates either a fragile modules ecosystem or stops the evolution of the Redis core. To solve this problem, the Redis core is decoupled from the modules API but still has low-level access to directly manipulate Redis’s data structure. There is also a big effort to provide a clean API that is not prone to misuse. For example, there is support for automatic memory management so that the context the command operates on collects the objects that are not explicitly freed by the user in order to free them when the command returns if needed. This makes writing modules a lot simpler.
Dvir Volk is a veteran engineer, entrepreneur, open source advocate, and former newspaper editor. Dvir began his tech career developing his own massively scalable web search engine, which is now integrated into many of Israel’s top websites. He later went on to cofound the social networking startup ILCU and served as director of engineering at Giraffic, a P2P video distribution provider. In his last role as chief architect at mobile startup EverythingMe, Dvir designed the company’s entire infrastructure around Redis, becoming one of the earliest members and active evangelists of the Redis community.
©2016, O’Reilly UK Ltd • (800) 889-8969 or (707) 827-7019 • Monday-Friday 7:30am-5pm PT • All trademarks and registered trademarks appearing on oreilly.com are the property of their respective owners. • email@example.com