Hierarchical solution?

Fredrik Lindmark fredrik at capestream.se
Thu Nov 24 20:49:25 PST 2005


Hi,

I'm checking around for some solutions to a newborn project, maybe 
someone can give me a hint if it would work out with memcached.
Havent been using anything similar before so it can turn up quite 
basic.. i wish :)

Like many others i want to cache the database to be more efficient.. 
for my purposes. It seems like the SQL-query cache is the most common 
solution.. yet i want to approach it another way.

Picture a hashtree... around 5-7 nodes deep. This tree is based of 
different data, depending on whats uniting the information.
like..

$$TREE{$server}{'db'}{$database}{'tb'}{$table}{'co'}{$col}{'ro'}{$row} 
= $val;
$$TREE{$server}{'db'}{$database}{'tb'}{$table}{'ro'}{$row}{'co'}{$col} 
= $val;
$$TREE{$server}{'db'}{$database}{'time'} = ...;

By importing a table, converting it into hash (its different ways to se 
a database in a hashtable.. even more when i add some analyzes on my 
own, thats why the 'tb','co','ro' strings are there for) and adding it 
to the structure i can work very efficiant with this cached 
information.

when i update a table, i simply delete the tree node. if no node 
exists.. we call the database.. its very close related to a database 
hash tie i believe, yet i  did my own thing to fit my purposes better..

anyway.
I need to figure out a way to scale this hash up on many processes... 
and many servers eventually. but let's start with processes...

how would you apply this structure to memcached?
What i've seen memcached is key = value based.. so if i make a:

	set('tree' => $TREE )

im stuck with the fact that the tree is a static hash tree below the 
key. If i want to remove one of the table node of a certain database.. 
i need to set the whole tree again. that means, the smallest change.. 
and the full tree is copied or modified... in a big and deep hash.. it 
feels far from good.

.. fill me in if im missing something here.

To be a dreamer.. what im looking for in the optimal case is a way to 
work with the hash like it was part of another module, one available 
for all processes running.. like $GLOB::TREE but, well.. one step 
higher, where you include all processes..

Any hint, recommendation would be of most help..

Regards,

Fredrik
fredrik at capestream.se



More information about the memcached mailing list