Skip to content

Commit

Permalink
Compress device configs when stored in Redis.
Browse files Browse the repository at this point in the history
ZEN-35069
  • Loading branch information
jpeacock-zenoss committed Oct 1, 2024
1 parent fe44020 commit 16a7196
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion Products/ZenCollector/configcache/cache/storage/device.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
import logging
import re
import types
import zlib

from functools import partial
from itertools import chain
Expand Down Expand Up @@ -660,6 +661,10 @@ def _deserialize(data):
# s-expressions, which are basically nested lists, and there's no JSON
# hook for lists. So, wrap the data into a JSON-object (a dict) and
# use a function to customize the decoding.
try:
data = zlib.decompress(data)
except zlib.error:
pass
data = '{{"config":{}}}'.format(data)
return unjelly(json.loads(data, object_hook=_decode_config))

Expand All @@ -682,7 +687,7 @@ def _decode_item(item):


def _serialize(config):
return json.dumps(jelly(config))
return zlib.compress(json.dumps(jelly(config)))


def _to_score(ts):
Expand Down

0 comments on commit 16a7196

Please sign in to comment.