UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'D2HRMsJKLqePt9JdU7fJ2V46ntKFPr1XR2ZnKpbMef8=' 
WHERE 
  key_id = '7964e7ec9799c9c86cadd4e467246c272067c49a5a3b71ac306ccd4efdb09447' 
  AND (
    token = 'D2HRMsJKLqePt9JdU7fJ2V46ntKFPr1XR2ZnKpbMef8=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00039