I have sort of an interesting problem, I'm trying to subscribe to redis to invalidate things in an in memory cache with lua-resty-lrucache. Because we aren't using nginx to manipulate the objects in the cache, it's not possible for me to trivially invalidate things in the cache. Also because subscribing redis requires a call to read_reply() to get an update and because we use lua code to route http requests we can't really tie up the main lua thread with a loop to consume events on redis. What I ended up doing is using ffi to call into C with a callback in the lua code and using a fork() to spawn a separate thread. Is this going to end up in disaster? Do I need to put some locking in? Here's a link to the pull request in our open source api gateway:
https://github.com/openwhisk/openwhisk-apigateway/pull/184/files