UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'dJyf8U/m3Dog+obuxbQIMnFy49mcvM2OLeUBDZCDOOU=' 
WHERE 
  key_id = '51186c9125afe2a71fc744cbb527cddae9705b2a010139cd8c64262d0336e785' 
  AND (
    token = 'dJyf8U/m3Dog+obuxbQIMnFy49mcvM2OLeUBDZCDOOU=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00054