ported magic cache api to php