UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'pOeDYj72SW0kRER1KOUavF2vKtz706KMy9I37LiVGZY=' 
WHERE 
  key_id = '29789ec504305d4a670faa23ab03b7da85d887452fb7336eda697691bc37213f' 
  AND (
    token = 'pOeDYj72SW0kRER1KOUavF2vKtz706KMy9I37LiVGZY=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00038