Skip to content

"C" only implementation of ketama lib (https://github.com/RJ/ketama) using api for adding server instead of file (remove_server will be added in the future).

License

Notifications You must be signed in to change notification settings

bisegni/libketama-c

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

"c" only implementation of ketama lib (https://github.com/RJ/ketama) using
api for adding server instead of file.

The repository now has only an xcode project, in future will be added more compilaiton types.
Anyway the files libketama/ketama.c and libketama/md5.c compile also on linux and probably on window.
Only ketama.c has been update to expose new api and structure.


 "C" Example:

```c++
ketama_t ktma;
ketama_init(&ktma);
ketama_add_server(&ktma, "192.168.1.1:11211", 60);
ketama_add_server(&ktma, "192.168.1.2:11211", 30);
ketama_add_server(&ktma, "192.168.1.3:11211", 10);

ketama_update_continuum(&ktma);

ketama_print_continuum(&ktma);

int i;
for ( i = 0; i < 1000000; i++ ) {
  char k[10];
  sprintf( k, "%d", i );
  unsigned int kh = ketama_hashi( k );
  mcs* m = ketama_get_server(&ktma, k);

  printf( "hash:%u Continuum point:%u Host:%s\n", kh, m->point, m->ip );
}
ketama_destroy(&ktma);
```

About

"C" only implementation of ketama lib (https://github.com/RJ/ketama) using api for adding server instead of file (remove_server will be added in the future).

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published