Skip to content

[improvement] [client] [naming module] disk cache do not work in some case #13336

@shalk

Description

@shalk

The naming module of nacos client have a class service holder.

Service holder have a diskcache feature which is a addition feature for memory cache.

The disk cache feature have some limited , It only take effect when server node changed.

In Production Env, some server nodes is stable and not change for long time.

So I want to improve feature to support diskcache when node is not changed and the file is not exists.

        if (diff.hasDifferent()) {
            NAMING_LOGGER.info("current ips:({}) service: {} -> {}", serviceInfo.ipCount(), serviceKey,
                    JacksonUtils.toJson(serviceInfo.getHosts()));
            
            if (!failoverReactor.isFailoverSwitch(serviceKey)) {
                NotifyCenter.publishEvent(
                        new InstancesChangeEvent(notifierEventScope, serviceInfo.getName(), serviceInfo.getGroupName(),
                                serviceInfo.getClusters(), serviceInfo.getHosts(), diff));
            }
            DiskCache.write(serviceInfo, cacheDir);
        }

Describe the bug
A clear and concise description of what the bug is.

when server node is not change , client disk cache is not enabled

Expected behavior
A clear and concise description of what you expected to happen.
when server node is not change , client disk cache is enabled

Actually behavior
A clear and concise description of what you actually to happen.
when server node is not change , client disk cache is not enabled

How to Reproduce
Steps to reproduce the behavior:

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See errors

Desktop (please complete the following information):

  • OS: [e.g. Centos]
  • Version [e.g. nacos-server 1.3.1, nacos-client 1.3.1]
  • Module [e.g. naming/config]
  • SDK [e.g. original, spring-cloud-alibaba-nacos, dubbo]

Additional context
Add any other context about the problem here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/discussionCategory issues related to discussion

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions