3liz / py-qgis-server

QGIS embbeded WMS/WFS/WCS asynchronous scalable http server
https://docs.3liz.org/py-qgis-server
Mozilla Public License 2.0
68 stars 16 forks source link

Is there a problem in the refresh_cache method ? #61

Closed TANK2003 closed 1 year ago

TANK2003 commented 1 year ago

In the refresh_cache method https://github.com/3liz/py-qgis-server/blob/master/pyqgisserver/qgsworker.py#L299

def refresh_cache(cls) -> None:
        if cls._cache_check_interval <= 0 or time() - cls._cache_last_check < cls._cache_check_interval:
            return
        LOGGER.debug("Refreshing cache")
        iface = cls.qgis_server.serverInterface()
        for (key, state) in cls._cache_service.refresh():
            # Remove from Qgis server ConfigCache
            if state == UpdateState.UPDATED:
                details = cls._cache_service.peek(key)
                iface.removeConfigCacheEntry(details.project.fileName())

        cls._cache_last_check = time()
dmarteau commented 1 year ago

This part of code is relevant only if you use the CACHE_CHECK_INTERVAL option for asynchronous cache invalidation.

In basic use case, the cache is always refreshed when the project is modified on disk or in database: cache is checked on cache_lookup(..) call.

TANK2003 commented 1 year ago

Yes i have try to use CACHE_CHECK_INTERVAL, bu it is not working as expecting. When check the code, it is as if whenever the value of CACHE_CHECK_INTERVAL, the cache will never be refresh

dmarteau commented 1 year ago

If the check_interval congiguration value cls. _cache_check_interval <= 0 the cache will be never refresh ?

if time() - cls._cache_last_check < cls._cache_check_interval the cache will be never refresh ?

The purpose of CACHE_CHECK_INTERVAL is to trigger refresh only at specified interval.

Of course, in all cases, projects are reloaded only if they have been modified.

dmarteau commented 1 year ago

Yes i have try to use CACHE_CHECK_INTERVAL, bu it is not working as expecting.

What was your expectation ?

TANK2003 commented 1 year ago

Thanks for all the details explanaition !

What was your expectation ?

I thought that the variable CACHE_CHECK_INTERVAL represented the maximum time between the generation of the cache, but between two requests, not that it is even without requests on server ; That is very good!

But I just did some tests, this condition is never true state == UpdateState.UPDATED (https://github.com/3liz/py-qgis-server/blob/master/pyqgisserver/qgsworker.py#L306) knowing that I use the default shceme (file)

dmarteau commented 1 year ago

But I just did some tests, this condition is never true state == UpdateState.UPDATED

It is true when a modified version of the project has been reloaded on a cache refresh.

github-actions[bot] commented 1 year ago

This issue is stale because it has been open for 30 days with no activity.

github-actions[bot] commented 1 year ago

This issue was closed because it has been inactive for 14 days since being marked as stale.