UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'KINtliwK1Z8eyQumEw8J8h323t2bDTOkq+QarDvjlps=' 
WHERE 
  key_id = 'ef6c8b1386a0ea03961b90348ced31b0878ab6c13104eda01322820181c18717' 
  AND (
    token = 'KINtliwK1Z8eyQumEw8J8h323t2bDTOkq+QarDvjlps=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00037