UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'qYFtuxpLVBwRoDHsAcTZs4AYoNvBkXE0Gg+x6WukZGA=' 
WHERE 
  key_id = 'b297181d7d31d7b99301bdb69c81c0c16c8e11b032eaa63a76b1987a620ba56d' 
  AND (
    token = 'qYFtuxpLVBwRoDHsAcTZs4AYoNvBkXE0Gg+x6WukZGA=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00032