UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'NEsRSjByOLfVk82lyCxgzXuVATUpKRtt14eZwOi7Y3s=' 
WHERE 
  key_id = '3cb2dee62cd70a01213469028f97b25da49c52e85263de1cda73b90e8734de5d' 
  AND (
    token = 'NEsRSjByOLfVk82lyCxgzXuVATUpKRtt14eZwOi7Y3s=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00032