I'll let others tackle your security question. On the cached dataset, why not use a
DBD::AnyData in-memory table. That way you just import from MySQL straight into an in-memory table and then query that table with SQL just as you'd query the actual MySQL table. Pair networks (our kind hosts) uses this technique. See
a PM talk about Pair Networks use of DBD::AnyData as a cache mechanism