|
23 | 23 | import json
|
24 | 24 | import logging
|
25 | 25 | import re
|
26 |
| -import sqlite |
27 | 26 | from typing import Union
|
28 | 27 | import uuid
|
29 | 28 |
|
|
34 | 33 | import yaml
|
35 | 34 |
|
36 | 35 | from msc_wis2node.env import (BROKER_HOSTNAME, BROKER_PORT, BROKER_USERNAME,
|
37 |
| - BROKER_PASSWORD, CACHE, CENTRE_ID, DATASET_CONFIG, |
38 |
| - TOPIC_PREFIX) |
| 36 | + BROKER_PASSWORD, CACHE, CACHE_EXPIRY_SECONDS, |
| 37 | + CENTRE_ID, DATASET_CONFIG, TOPIC_PREFIX) |
39 | 38 | from msc_wis2node.util import get_mqtt_client_id, get_mqtt_tls_settings
|
40 | 39 |
|
41 | 40 | LOGGER = logging.getLogger(__name__)
|
@@ -77,7 +76,7 @@ class WIS2Publisher:
|
77 | 76 | def __init__(self):
|
78 | 77 | """initialize"""
|
79 | 78 |
|
80 |
| - self.cache = memcache_base.Client(CACHE] |
| 79 | + self.cache = memcache_base.Client(CACHE) |
81 | 80 | self.datasets = []
|
82 | 81 | self.tls = None
|
83 | 82 |
|
@@ -183,12 +182,13 @@ def publish_to_wis2(self, dataset: dict, url: str) -> None:
|
183 | 182 | )
|
184 | 183 |
|
185 | 184 | LOGGER.debug('Checking for data update')
|
186 |
| - if message['properties']['data_id'] in self.cache: |
| 185 | + if self.cache.get(message['properties']['data_id']) is not None: |
187 | 186 | update_link = deepcopy(message['links'][0])
|
188 | 187 | update_link['rel'] = 'update'
|
189 | 188 | message['links'].append(update_link)
|
190 | 189 | else:
|
191 |
| - self.cache.append(messages['properties']['data_id'] |
| 190 | + self.cache.set(message['properties']['data_id'], |
| 191 | + CACHE_EXPIRY_SECONDS) |
192 | 192 |
|
193 | 193 | cache = dataset.get('cache', True)
|
194 | 194 | if not cache:
|
|
0 commit comments