https://github.com/lunamultiplayer/cachedquicklz
Compress and decompress with QuickLz while keeping low the Garbage Collector
https://github.com/lunamultiplayer/cachedquicklz
allocate allocation cache cached collector compress compressor decompress decompressor garbage garbage-collection garbage-collector gc pool pooled quicklz
Last synced: 3 months ago
JSON representation
Compress and decompress with QuickLz while keeping low the Garbage Collector
- Host: GitHub
- URL: https://github.com/lunamultiplayer/cachedquicklz
- Owner: LunaMultiplayer
- License: gpl-3.0
- Created: 2018-09-29T23:56:48.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2019-10-18T09:39:37.000Z (over 5 years ago)
- Last Synced: 2025-03-05T12:46:28.158Z (3 months ago)
- Topics: allocate, allocation, cache, cached, collector, compress, compressor, decompress, decompressor, garbage, garbage-collection, garbage-collector, gc, pool, pooled, quicklz
- Language: C#
- Homepage:
- Size: 68.4 KB
- Stars: 2
- Watchers: 7
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- Funding: .github/FUNDING.yml
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
---
# Cached compression/decompression with [QuickLz](http://www.quicklz.com/)
*Allows you to compress and decompress with [QuickLz](http://www.quicklz.com/) while keeping low the GC pressure*
### Main features:
- Fast compression/decompression using [QuickLz](http://www.quicklz.com/) algorithm
- Includes an array pool to request/recycle arrays in case you want to return them once you've compressed/decompressed their data### Usage:
##### Compress:
```CSharp
var length = 5000;
var data = new byte[length]
//Fill up the "data" array...
CachedQlz.Compress(ref data, ref length);
//Now "data" is an array with the compressed bytes. If you want to check it's length use the variable "length"
//Do NOT use data.Length! It might be bigger as it came from a cached array!
```##### Decompress:
```CSharp
//"data" is an array with compressed bytes...
CachedQlz.Decompress(ref data, out var decompressedLength);
//Now "data" is an array with the decompressed bytes. If you want to check it's length use the variable "length"
//Do NOT use data.Length! It might be bigger as it came from a cached array!
```### Array pool usage:
##### Request an array from the pool:
```CSharp
var array = ArrayPool.Spawn(4);
//Caution, array.Length will 8 instead of 4 as the cache system uses values based on powers of two
```##### Return an array to the pool:
```CSharp
ArrayPool.Recycle(array);
```---
### Status:
| Branch | Build | Tests |
| ---------- | -------- | -------- |
| **master** |[](https://ci.appveyor.com/project/gavazquez/cachedquicklz/branch/master) | [](https://ci.appveyor.com/project/gavazquez/cachedquicklz/branch/master/tests)---