Cache kernels by queue id rather than by context id

This solves potential data race conditions when there are several
queues per context.