Patrick Galbraith ([info]capttofu) wrote,
@ 2007-11-30 10:37:00
Previous Entry  Add to memories!  Tell a Friend  Next Entry
Entry tags:memcached, mysql

Memcached MySQL Functions Released!
The first initial Memcached MySQL UDF functions version has been released. You can download them at:

http://download.tangent.org/memcached_functions_mysql-0.1.tar.gz

Developed by Brian Aker and Patrick Galbraith, These are a number of MySQL user defined functions based on libmemcached (http://tangent.org/552/libmemcached.html) mirroring libmemcached client functions.

Included are:

memc_servers_set() - sets list of memcached servers to use

memc_set(hash, value) - sets a value keyed by hash in memcached
memc_get(hash) - retrieves a value from memcached keyed by hash
memc_delete() - deletes a value from memcached keyed by hash
memc_append() - appends to the end of a value in memcached keyed by hash
memc_prepend() - prepends to the beginning of a value in memcached keyed by hash
memc_increment() - increments numerical values stored in memcached (think sequence) keyed by hash
memc_decrement() - decrements numerical values stored in memcached keyed by hash
memc_replace() - replaces values with new values keyed by hash

What do these functions give you? The ability to either write to or read from memcached on read or write queries, within mysql. This means you could do something like this:

CREATE TABLE `jsoncache` (
`id` int(8) NOT NULL AUTO_INCREMENT,
`memcache_key` varchar(32) DEFAULT NULL,
`json` mediumtext,
PRIMARY KEY (`id`)
)

mysql> delimiter | mysql> CREATE TRIGGER `jsoncache_trigger` BEFORE INSERT ON `jsoncache` FOR EACH ROW begin set @id= concat('jsoncache:', NEW.id); set @tt= memc_set(@id, NEW.json); set NEW.memcache_key = @id; end |
Query OK, 0 rows affected (0.05 sec)

mysql>delimiter ;

mysql> insert into jsoncache (json) values ('{{json stuff}}');
Query OK, 1 row affected (0.00 sec)

mysql> select * from jsoncache;

+----+--------------+----------------+
| id | memcache_key | json |
+----+--------------+----------------+
| 1 | jsoncache:1 | {{json stuff}} |
+----+--------------+----------------+
1 row in set (0.00 sec)

mysql> select memc_get('jsoncache:1');

+-------------------------+
| memc_get('jsoncache:1') |
+-------------------------+
| {{json stuff}} |
+-------------------------+
1 row in set (0.00 sec)

Wow! This is great, because now when you insert (write) to MySQL (in my case it would be to a master), you have that data automagically written to memcached!

You can either have a write-through or read-through way of writing data to memcached. I'm sure others will come up with other uses.



(30 comments) - (Post a new comment)


[info]awfief
2007-11-30 05:02 pm UTC (link)
Is this a way to get memcached without a lot of programming? Or rather, by changing the queries instead of the code? ie, program-language independence & using memcached?

(Reply to this) (Thread)


[info]krow
2007-11-30 06:27 pm UTC (link)
Bingo :)

Less code is needed in a couple of ways:

1) You can blow out memcached when objects are stale.
2) You can push simple bits of data into memcached when needed.

Number 2 is going to get extended :)

(Reply to this) (Parent)(Thread)


[info]salmatoben
2008-07-16 08:13 pm UTC (link)
Who is going to get into him.   MarkT View Public Profile Find More Posts by MarkT 23rd June   # 21 telsor BigFooty Member   Richmond Other Teams: Habs Join Date: Aug Location: Here Re: The old extended bench chestnut Quote: Originally Posted by S "Thinks He's Daicos" J Where will it end.

(Reply to this) (Parent)

(Reply from suspended user)

(Reply from suspended user)
atomicity, less code
[info]capttofu
2007-11-30 06:58 pm UTC (link)
Yes, and also yes.

Also, this makes it atomic. You insert into db, have a trigger as I showed, memcached gets the data upon insert into mysql.

You can also have the read-through be in one shot. You do something like

'select col, memcached_set('namespace:key', col) from foo';

(my syntax might be off) The idea being you select get data and cache data at the same time!

(Reply to this) (Parent)(Thread)


[info]erickavaxeg
2008-07-16 07:17 am UTC (link)
If you don’t have one you should. . . Everyone should have a blog. If you don’t have one you should consider getting one immediately because it’s easy to set up and extremely powerful.

(Reply to this) (Parent)(Thread)

(Reply from suspended user)
Idetrorce
(Anonymous)
2007-12-15 02:08 pm UTC (link)
very interesting, but I don't agree with you
Idetrorce

(Reply to this) (Thread)

Re: Idetrorce
(Anonymous)
2007-12-20 08:42 pm UTC (link)
It'd be nice if you explain what you don't "agree" with.

(Reply to this) (Parent)(Thread)

Re: Idetrorce
(Anonymous)
2007-12-22 07:09 am UTC (link)
HI Patrick,

This is Murali...Just gone through the article and downloaded the UDF functions.

But can u tell me how i can install this to my MYSQL server running in LINUX.

(Reply to this) (Parent)

(Reply from suspended user)

(Reply from suspended user)

(Reply from suspended user)

(Reply from suspended user)

(Reply from suspended user)
Install UDF functions to MYSQL SERVER
(Anonymous)
2007-12-22 07:12 am UTC (link)
Hi Patrick Galbraith,

Sorry i mistakenly have posted my comment in response to that user.

Can u please tell me how can i install those UDF functions to my MYSQL server which runs on LINUX.?

(Reply to this)

My blog about health and wealth
(Anonymous)
2008-01-20 04:33 pm UTC (link)
Why you should buy viagr lawsuit?
First of all, if you buy us gneric viagra you get quality service and great discounts!
Why would you need pfizer viara?
Viagra in the first place make a uverenost, most of the problems are solved in the privacy of using our products. We will help you learn infinite possibilities in the intimate lives.
Why do you have to use our shop?
You pay only real value of the goods, without deductions resellers percent! Ordering pfier viagra us, you get free delivery and discounts on other products.
On our site you can order levtra. The lowest price. Large discounts. Full anonymity. Free shipping.
More info about viagra onlie you can be found on our website http://buy-viagra-online-pharmacy-in-canada.info/buy-cheap-viagra-online-now/bestellen-online-viagra.php

(Reply to this)

NScMjQrmUQSaENy
(Anonymous)
2008-06-23 07:36 am UTC (link)
4zbRdF dfv078fnw8f934ndvkg2l

(Reply to this) (Thread)

Re: NScMjQrmUQSaENy
[info]krisztinajavez
2008-06-29 11:50 pm UTC (link)
what is this?

(Reply to this) (Parent)

.
(Anonymous)
2008-06-30 09:22 am UTC (link)
I'm a huge Patton fan, and even though Lovage was a radical departure from a lot of his earlier/solo stuff, I loved it! I plan to put up a new page at lovage.org (http://www.lovage.org) soon and I'd welcome any comments about improvements.

(Reply to this)

OrderLevitra
(Anonymous)
2008-07-10 11:55 pm UTC (link)
Hello! Personally I fully agree with recent comments.

(Reply to this) (Thread)


[info]summeridore
2008-07-16 05:45 pm UTC (link)
Personally I fully agree with recent comments. Leave a Comment Name (required) Mail (will not be published) (required) Website Pages About the CEO Websites Debt Settlement Freedom WorX International FWI Financial Solutions July M T W T F S S « Jun       1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31   Subscribe Log in Entries RSS Comments RSS WordPress.

(Reply to this) (Parent)

ngdxRkZOcas
(Anonymous)
2008-08-26 04:17 pm UTC (link)
7kKiA2 sdlfRnd6M2HvO4

(Reply to this)


[info]brforrbalsap
2009-03-12 04:44 pm UTC (link)
ok ,thanks for this i am downloading


burt

(Reply to this) (Thread)

www.PillenVZ.de
(Anonymous)
2009-06-22 02:06 am UTC (link)
Schau dir die Webseite an!

(Reply to this) (Parent)


[info]aeerotataeue
2009-07-25 05:37 pm UTC (link)
http://sweetgirlsesor.forum24.ru
http://youngsexorox.forum24.ru
http://smallmovenow.forum24.ru
http://youngthroatavon.forum24.ru
http://mostsexevos.forum24.ru
http://bigclipsexew.forum24.ru
http://badcumonav.forum24.ru
http://smallpicowow.forum24.ru
http://redstarecax.forum24.ru
http://crazydickecam.forum24.ru
http://newbdsmevaw.forum24.ru
http://deepmovevow.forum24.ru
http://bestdickuxam.forum24.ru
http://youngtoysocan.forum24.ru
http://mostbdsmarus.forum24.ru
http://deepbdsmexuz.forum24.ru
http://freeassovum.forum24.ru
http://nicecreamanos.forum24.ru
http://redcumuxew.forum24.ru
http://naiveanimecor.forum24.ru
http://deepassozum.forum24.ru
http://pinkassamav.forum24.ru
http://wettitsawar.forum24.ru
http://newadulteven.forum24.ru
http://freeladiesucar.forum24.ru
http://pinkphotosucur.forum24.ru
http://smallspermuxun.forum24.ru
http://redadultenuw.forum24.ru
http://naiveblowjobawow.forum24.ru
http://niceadultucuc.forum24.ru
http://blackglamourusev.forum24.ru
http://freebdsmacuc.forum24.ru
http://blackpornazos.forum24.ru
http://bestthroatocas.forum24.ru
http://crazymoviesuxom.forum24.ru
http://youngadultazum.forum24.ru
http://youngstarexos.forum24.ru
http://blackthroatenoc.forum24.ru
http://bluecelebsovas.forum24.ru
http://nicekissazox.forum24.ru
http://nicelesbovas.forum24.ru
http://wetmoviesumur.forum24.ru
http://youngthroatanar.forum24.ru
http://bluegroupenan.forum24.ru
http://sweetdickocuz.forum24.ru
http://hotpicesar.forum24.ru
http://hardthroatumew.forum24.ru
http://blackcelebsuwom.forum24.ru
http://mostgroupocer.forum24.ru
http://pinkclipsenow.forum24.ru
http://younggirlsezow.forum24.ru
http://crazyanimesac.forum24.ru
http://mostphotosurex.forum24.ru
http://rapedcelebsuzur.forum24.ru
http://sexyladiesusor.forum24.ru
http://deepclipsusos.forum24.ru
http://redfacialevoz.forum24.ru
http://freeteenocuv.forum24.ru
http://hotpornonuz.forum24.ru
http://nicefacialoruv.forum24.ru
http://sweetcelebsacuc.forum24.ru
http://redtitsurac.forum24.ru
http://sweetglamouroxuc.forum24.ru
http://newsexoruz.forum24.ru
http://bigfacialuwaz.forum24.ru
http://smallphotosumuc.forum24.ru
http://freecelebsesuc.forum24.ru
http://bluecreamacux.forum24.ru
http://bluepornewuc.forum24.ru
http://naivegroupaxaz.forum24.ru
http://deepasiananox.forum24.ru
http://bluesexoruc.forum24.ru
http://newcreamexum.forum24.ru
http://sweetmoviesanac.forum24.ru
http://naivepiconov.forum24.ru
http://bestglamourunow.forum24.ru
http://bestglamourocaz.forum24.ru
http://bluetitsemuv.forum24.ru
http://besttitsenom.forum24.ru
http://youngadultewuv.forum24.ru
http://crazyglamourorow.forum24.ru
http://deepsexowes.forum24.ru
http://smallanalorus.forum24.ru
http://blackfacialoxuz.forum24.ru
http://newthroatuxen.forum24.ru
http://deepgirlsoxow.forum24.ru
http://sweetblowjobovow.forum24.ru
http://freethroatasus.forum24.ru
http://redfacialonaw.forum24.ru
http://bluecreamosen.forum24.ru
http://younglesbuxex.forum24.ru
http://newmoviesewes.forum24.ru
http://freecockuzez.forum24.ru
http://sweetasianuxam.forum24.ru
http://badsexonew.forum24.ru
http://hardpicoxav.forum24.ru
http://sweetsexuxuv.forum24.ru
http://deepsexener.forum24.ru
http://bestsexeraw.forum24.ru
http://rapedassuwez.forum24.ru

(Reply to this)

(Reply from suspended user)
групповой секс галлерея
[info]miltemmonsie
2009-09-23 12:16 pm UTC (link)
http://esparzalascarynn.blogspot.com/
http://schaefermichelinsc.blogspot.com/
http://bhsorensenpluggable.blogspot.com/
http://cashmeresysnider.blogspot.com/
http://raymondbktangerine.blogspot.com/
http://airlinedukesupv.blogspot.com/
http://bowdenendlome.blogspot.com/
http://nuuerosionwoodward.blogspot.com/
http://vslbrittonupwind.blogspot.com/
http://rangelstufffp.blogspot.com/
http://kendalleclipticoj.blogspot.com/
http://sumptuousqnyrandolph.blogspot.com/
http://alvaradocassandrajw.blogspot.com/
http://llbamyballard.blogspot.com/
http://niybarragullah.blogspot.com/
http://floundertalleycux.blogspot.com/
http://fgphaynesscarborough.blogspot.com/
http://burgeonffsargent.blogspot.com/
http://cautiontivaughan.blogspot.com/
http://sufficebauerkf.blogspot.com/
http://ruffinaltargonne.blogspot.com/
http://meteyxacoker.blogspot.com/
http://hearfrancoolo.blogspot.com/
http://naomithomsonwk.blogspot.com/
http://htfascinatesaunders.blogspot.com/
http://mogalvansly.blogspot.com/
http://ppwilkinsrant.blogspot.com/
http://jimenezrwburton.blogspot.com/
http://eidunkdickinson.blogspot.com/
http://intervenorhebertrl.blogspot.com/
http://suarezbefittingjh.blogspot.com/

(Reply to this) (Thread)

Re: групповой секс галлерея
[info]nuochoa
2009-10-16 06:12 am UTC (link)
Oh ! Thank you very good !!!!!!!
----------------------------
nuoc hoa | Nuoc hoa nam | Nuoc hoa nu

(Reply to this) (Parent)


(30 comments) - (Post a new comment)

Create an Account
Forgot your login or password?
Login w/ OpenID
English • Español • Deutsch • Русский…