UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'uc2ySh9g92tdXkiqt5MRQBsmG4ZBFstIIsI+ihxrrvA=' 
WHERE 
  key_id = '782721d204561285ee5c8c630603b8db058a3510e788fb7e7fe63842437d0918' 
  AND (
    token = 'uc2ySh9g92tdXkiqt5MRQBsmG4ZBFstIIsI+ihxrrvA=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00103