Elegance of a database API matters. Frequently, database APIs suit the database designer, rather than the programmer's desire for elegance and efficiency. This article pursues both: firstly, by comparing the Lua APIs for two separate databases, Redis and YottaDB. Secondly, it looks under the API covers at how object orientation can help to retain API efficiency. Finally, it benchmarks both databases using each API to implement a 3n+1 sequence generator (of Collatz Conjecture fame). It covers the eccentricities of the Lua APIs, the databases, and the nifty choice of benchmark tool, presenting benchmark results of each database's unique design.
翻译:数据库API的优雅性至关重要。通常,数据库API更贴合数据库设计者的需求,而非程序员对优雅与效率的追求。本文从两方面展开探讨:首先,通过比较两种独立数据库(Redis与YottaDB)的Lua API;其次,深入剖析API底层机制,探讨面向对象设计如何助力保持API效率。最后,本文使用两种API分别在两个数据库中实现3n+1序列生成器(以Collatz猜想闻名)进行基准测试。研究涵盖Lua API的特性差异、数据库的独有机制,以及基准测试工具的巧妙选择,并呈现了两种数据库独特设计对应的基准测试结果。