lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Hello,
I have a multithreaded C++ program

At the beginning when the program starts, I pre-populate my read-only
cache with about 80MB of data
The data is essentially hiearchical and fits well into Lua.  It changes
4 times per day, where I essentially reload it with a fresh copy of that
80MB data

Then I access it by key.

Today I use hard coded C++ class to keep the data in main process
memory, and a lock for data acces

I would like to change this cache into a Lua-backed in memory table
acting as that cached data structure.
For couple of reasons:

a)I would like to support additive schema changes in my cached data
without coding (I can use JSON parser converting into lua table on load)

b) in my basic experiments LuaTable access by Key is as fast as my
native data structure

c) I will need to implement the same module in Java, so I will be using
LuaJ to do this, and doing the cache in Lua will let me keep the same
code base for that piece


I would like to know what are advised design patterns/existing libraries
that would allow me to share this lua-backed in memory cache across
multiple threads with as little locking as possible (considering that
will need to in cache reloads, and it is ok for me to allocate double
the 80MB, if needed for the lock-free reload)

thx in advance

-- 
http://www.fastmail.fm - Email service worth paying for. Try it for free