0

I am coding a software that has "cloud configs", and I need a way to reduce the contents of the configs so I can save some storage in my db, I am looking for something like this and I couldnt find any resource that could have helped me.

I need to transform this

{ example: true, example2: 5, example3: false }

into something like this

c6ec15ea-37c2-4b6d-adcc-8616e913e2d8

5mf
  • 1
  • Zip them? You can store B64 representations – mplungjan Jan 05 '22 at 19:37
  • 2
    Are you really going to be saving that much? Does your DB not have any compression built in? If it's large text is there a benefit to using the DB and not a file? – Dave Newton Jan 05 '22 at 19:42
  • Typically when you reduce the size of something there is a chance for information loss, simply due to the nature of compression. Based on your example (*or at least what you seem to be asking for*), it seems like there would be a risk in losing important config data by trying to convert/compress and then decompress the data. – EssXTee Jan 05 '22 at 19:51
  • 1
    @EssXTee Can you provide an example of a lossy text compression mechanism? I've only ever seen 1-1 algos because a loss of precision in *text* would render decompression useless. – Dave Newton Jan 05 '22 at 20:16
  • @EssXTee not really if you're not using a lossy compression format – kevinSpaceyIsKeyserSöze Jan 05 '22 at 20:21
  • @DaveNewton 1-1 would be the best case scenario for this based on OP's question, which is what I was getting at. They claimed they wanted something like `c6ec15ea-37c2-4b6d-adcc-8616e913e2d8` which implies a reduction during compression (*40 characters originally down to 36 characters*), thus rendering the decompression useless for configs. – EssXTee Jan 05 '22 at 20:27
  • @kevinSpaceyIsKeyserSöze lossy compression would absolutely reduce the size/amount of data, but it defeats the purpose of what OP wants and is trying to do. They want to reduce the size of configuration data, which isn't feasible without losing some of that config data, making the compressed config data effectively useless. – EssXTee Jan 05 '22 at 20:31
  • @EssXTee This *could* be losslessly compressed down to lower than "36 characters" in a variety of ways, though. But I feel like you've missed my point that compression is not intrinsically lossy. – Dave Newton Jan 05 '22 at 20:31
  • @DaveNewton You asked for an example of lossy text compression. [Here](https://studio.code.org/projects/applab/hxXJIEGg2yza_Q7t9W04xg) is an example. Lossy compressed text. As discussed it is not feasible due to loss of config data. The example OP gave has a similar problem, which was my point. "36 characters" was purely from OPs example, but yes there was ways to reduce the actual text and keep the data structure, which is **similar** to what *minified* or *obfuscated* code sometimes does. – EssXTee Jan 05 '22 at 20:38

0 Answers0