UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'Rry924vrDERunRpYTBtEj6D82KybD59w+gLBlBgdSZM=' 
WHERE 
  key_id = '87436a50d888eef75b57a10949cc97b02e71a88a0aa6ca0d07c58d38abcee602' 
  AND (
    token = 'Rry924vrDERunRpYTBtEj6D82KybD59w+gLBlBgdSZM=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00032