ported magic cache api to lua