Toru's Multi Storage Patch

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


Hi!

I've been studying the patch from Toru Maesaka on making memcached  
have a plugable storage backend:
http://alpha.mixi.co.jp/dist/memcached-1.2.4_modularexp-0.0.5.tar.gz

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);
   int (*ext_del)(void*, const void*, const int);
   int (*ext_flush)(void*, const char*);
} MMCSTORAGE;

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.

Cheers,
	-Brian

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 tangent.org
Seattle, Washington
http://krow.net/                     <-- Me
http://tangent.org/                <-- Software
http://exploitseattle.com/    <-- Fun
_______________________________________________________
You can't grep a dead tree.




More information about the memcached mailing list