Toru's Multi Storage Patch

Brian Aker brian at
Sat Feb 2 00:48:22 UTC 2008


I've been studying the patch from Toru Maesaka on making memcached  
have a plugable storage backend:

What I am wondering is how to get this into the main distribution. I  
see some problems in the way that he went about what he did, but  
mostly it looks good. What he has done is refactored the main storage  
functions such that the function calls come from this structure:

typedef struct {
   void *opaque_engine;  /* pointer to the database handle */
   void *dlink_handler;  /* dynamic library handler */
   char *dboject_name;   /* name of the db object to link to */
   int max_dbsize;       /* maximum database size */
   int curr_size;        /* current size of the database */
   int bucket_num;       /* optional value for buckets */

   /* functions to be dynamically loaded */
   void *(*ext_new)(void);
   int (*ext_open)(void*, const char*);
   void (*ext_close)(void*);
   int (*ext_conf)(void*, const int, const char*);
   void *(*ext_get)(void*, const void*, const int, int*);
   int (*ext_put)(void*, const void*, const int, const void*, const  
   int (*ext_del)(void*, const void*, const int);
   int (*ext_flush)(void*, const char*);

He has left out increment/decrement, but I believe those would need to  
be handled as well (if you want to push atomic operations into the  
engine that is).

Thoughts? Toru's method involves if/else around calls, personally I  
would prefer putting all logic behind the API.


BTW it took years to do this in MySQL. I started in 4.1 on  
refactoring, and the work was not completed till 5.1.

Brian "Krow" Aker, brian at
Seattle, Washington                     <-- Me                <-- Software    <-- Fun
You can't grep a dead tree.

More information about the memcached mailing list