Skip to content

Latest commit

 

History

History
38 lines (34 loc) · 1.31 KB

File metadata and controls

38 lines (34 loc) · 1.31 KB

libconsistent

C library for various types of consistent hashing

Support consistent hashing algorithms

  • consistent hashing
  • ketama consistent hashing
  • jump consistent hashing

How to install

Copy libconsistent.c, libconsistent.h files and compile with your project.

Usage

consistent hashing

cons_hash *cons = chash_create();
chash_add_server(cons, "1.1.1.1:1111");
server_info *chash_server = chash_get_server(cons, "test_key");
chash_del_server(cons, chash_server);

ketama consistent hashing

ketama_hash *ketama = ketama_create();
ketama_add_server(ketama, "1.1.1.1:1111");
server_info *ketama_server = ketama_get_server(ketama, "test_key");
ketama_del_server(ketama, ketama_server);

jump consistent hashing

jump_hash *jump = jump_create();
jump_add_server(jump, "1.1.1.1:1111");
server_info *jump_server = jump_get_server(jump, "test_key");
// jump hashing doesn't support jump_del_server api

reference