UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'qxca351S1e/21wSvv8Gyern+PwB0Ab/L0SwICZYVNmU=' 
WHERE 
  key_id = '001842709b48924e16ed160771843314bf9773ba1707ec5c689da36ae3335973' 
  AND (
    token = 'qxca351S1e/21wSvv8Gyern+PwB0Ab/L0SwICZYVNmU=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00031