UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'CYJAJSNhrXMGk3CT3PnNfOVKrJKo0+tCDn57JwtaAgQ=' 
WHERE 
  key_id = '5582fc72a1e878051515d26886d6c8cb0fe9576039ddabee591df8288eca3d34' 
  AND (
    token = 'CYJAJSNhrXMGk3CT3PnNfOVKrJKo0+tCDn57JwtaAgQ=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00058