UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = '0LjPir4UvLporfktLLzAXrTxlgg06aBQmepANyeyLow=' 
WHERE 
  key_id = 'b9ecafd5acf8b35d68c31e417378f43142a8be5077f165e7662b735b197965e0' 
  AND (
    token = '0LjPir4UvLporfktLLzAXrTxlgg06aBQmepANyeyLow=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00030