UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'q8deYyJ/G+nhI4vcDTEWWt8OrG5fEwO88BTdAfmR7zk=' 
WHERE 
  key_id = '51b1fd43756120749ed09af9790d2848714de358388dbe6a04c19b1b32640642' 
  AND (
    token = 'q8deYyJ/G+nhI4vcDTEWWt8OrG5fEwO88BTdAfmR7zk=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00025