UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'r2InB17R7qgtpqqItbyh3vamSxhpw7OYzf537MDFiYQ=' 
WHERE 
  key_id = 'ba08d1a270533321657475c2480400b33d528e0dc02303a2652b87e68507d2c8' 
  AND (
    token = 'r2InB17R7qgtpqqItbyh3vamSxhpw7OYzf537MDFiYQ=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00032