• Stars
    star
    210
  • Rank 187,585 (Top 4 %)
  • Language
    C#
  • License
    MIT License
  • Created over 4 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

⚡ A compression library that implements many compression algorithms such as LZ4, Zstd, LZMA, Snappy, Brotli, GZip, and Deflate. It helps you to improve performance by reducing Memory Usage and Network Traffic for caching.

NuGet Badge License: MIT Build Status

EasyCompressor

A compression library that implements many compression algorithms such as LZ4, Zstd, LZMA, Snappy, Brotli, GZip, and Deflate. It helps you to improve performance by reducing Memory Usage and Network Traffic for caching.

Nuget Packages

Package Name Version Description
EasyCompressor Contains GZip, Deflate and (Brotli available only in .NETCore2.1, .NETStandard2.1 and above)
EasyCompressor.BrotliNET Contains Brotli using Brotli.NET (for erlier than .NETCore2.1, .NETStandard2.1)
EasyCompressor.LZ4 Contains LZ4 using K4os.Compression.LZ4
EasyCompressor.LZMA Contains LZMA using LZMA-SDK
EasyCompressor.Snappy Contains Snappy using Snappy.Standard
EasyCompressor.Zstd Contains Zstd (ZStandard) using ZstdNet
EasyCaching.Extensions.EasyCompressor This integrates EasyCaching with EasyCompressor. (How to use)

Note :

LZ4, GZip, Deflate, Brotli, and LZMA are cross-platform because these are complete implementations with C#. (also BrotliNet too because this is a wrapper of brotli native library for win/linux/osx)

Zstd and Snappy are not cross-platform, because they are just a wrapper of the native library for windows.

Features

  • Supports and implements many compression algorithms.
  • Supports async/await and CancellationToken.
  • Supports woking with multiple compressors with specified names
  • Supports Stream as most as possible (depending on the underlying library)
  • Compress/Decompress between byte[], Stream, StreamReader and StreamWriter.

Get Started

1. Install Package

PM> Install-Package EasyCompressor.LZ4

2. Add Services

public void ConfigureServices(IServiceCollection services)
{
    //...
    services.AddLZ4Compressor();

    //or services.AddGZipCompressor();      package : EasyCompressor
    //or services.AddDeflateCompressor();   package : EasyCompressor
    //or services.AddBrotliCompressor();    package : EasyCompressor
    //or services.AddBrotliNetCompressor(); package : EasyCompressor.BrotliNET
    //or services.AddZstdCompressor();      package : EasyCompressor.Zstd
    //or services.AddLZMACompressor();      package : EasyCompressor.LZMA
    //or services.AddSnappyCompressor();    package : EasyCompressor.Snappy
}

3. Use it

using EasyCompressor;

// Inject (ICompressor compressor)

// Compress
var compressedBytes = compressor.Compress(inputBytes);

// Decompress
var uncompressedBytes = compressor.Decompress(compressedBytes);

Benchmark

Tips and Results

Original data size is:

  • 89,535 bytes (about ≈ 90 KB) (binary serialized output of a json file by messagepack).

Compressed data size (for example):

  • 776 bytes for Zstd (115x compression ratio) that results in 99.13% memory and bandwidth saving.
  • 1,234 bytes for LZ4 (72x compression ratio) that results in 98.62% memory and bandwidth saving.

Maximum Compression:

  • Brotli
  • Zstd
  • LZMA
  • LZ4

Fastest Speed:

  • Zstd
  • Snappy
  • LZ4

Most Efficient:

  • Zstd (windows only package)
  • LZ4 (cross-platform package)

Moderated:

  • GZip
  • Deflate

Compression Ratio : higher is better Benchmark

Contributing

Create an issue if you find a BUG or have a Suggestion or Question. If you want to develop this project :

  1. Fork it!
  2. Create your feature branch: git checkout -b my-new-feature
  3. Commit your changes: git commit -am 'Add some feature'
  4. Push to the branch: git push origin my-new-feature
  5. Submit a pull request

Give a Star! ⭐️

If you find this repository useful, please give it a star. Thanks!

License

EasyCompressor is Copyright © 2020 Mohammd Javad Ebrahimi under the MIT License.

More Repositories

1

Awesome-Microservices-DotNet

💎 A collection of awesome training series, articles, videos, books, courses, sample projects, and tools for Microservices in .NET
2,284
star
2

Awesome-Nuget-Packages

📦 A collection of awesome and top .NET packages sorted by most popular needs.
226
star
3

SeoTags

SeoTags create all SEO tags you need such as meta, link, twitter card (twitter:), open graph (og:), and JSON-LD schema (structred data).
C#
113
star
4

Awesome-Tools-For-WebDevelopers

Awesome Tools For Web Developers
67
star
5

AspNetCore.Unobtrusive.Ajax

Unobtrusive Ajax Helpers (like MVC5 Ajax.BeignForm and Ajax.ActionLink) for ASP.NET Core
C#
48
star
6

AspNetCore-WebApi

Professional REST API design with ASP.NET Core and WebAPI
C#
44
star
7

RamDisk

RamDisk is a library for create virtual disk drive on system memory
C#
41
star
8

Elasticsearch-NEST-CheatSheet-Tutorials

A collection of most used Queries, Methods, and Concepts of Elasticsearch and NEST (.NET Client) with related samples and refrences, and also useful tutorials and sample projects.
C#
31
star
9

SqlInMemory

SqlInMemory is a library for creating SqlServer database on Memory instead of hard disk, at last Drops and Disposes database when you're done with it. This is useful for Integration Testing.
C#
27
star
10

DNZ.MvcComponents

A set of useful UI-Components (HtmlHelper) for ASP.NET Core MVC based-on Popular JavaScript Plugins (Experimental project).
JavaScript
27
star
11

Jwt-Encryption-AspCore

Encrypt/Secure JWT (Json Web Token) in ASP.NET Core. Its also called JWE (Json Web Encryption)
C#
25
star
12

DNZ.SEOChecker

SEO Checker and Recommander Plugin (like wordpress Yoast) for ASP.NET Core.
C#
20
star
13

SharpMt940Lib.Core

SharpMT940Lib implements the MT940 format in C# and is based on specifications of multiple banks. You can use it as a base for financial software or for conversions to other formats like CSV or OFX.
C#
18
star
14

auto-mapping

Auto mapping with AutoMapper and Reflection in ASP.NET Core
C#
14
star
15

Best-Free-Admin-Dashboard-Template

Best Free Admin Dashboard Template
12
star
16

SmartCacheManager

SmartCacheManager is a smart caching module to cache objects with resilient and variable expiration timing that is useful for caching result of web services.
C#
10
star
17

Micro-Optimization-Samples

Micro Optimization Samples
C#
10
star
18

awesome-dotnet-core-education

⚡ Collection of useful articles and resources to learning and practicing about .Net Core and its related technologies. 😉
C#
10
star
19

EasyMongo

A full-feature and easy-to-use Repository implementation for MongoDb
C#
7
star
20

NopLocalization

Simplified multi-language POCO localization for ASP.NET Core
C#
7
star
21

EFCore-Include-Filtering-Benchmark

EFCore Include Filtering Benchmark
C#
5
star
22

.Net-Async-Resources

Useful resources about async, threading, and channel in .Net platform. This repository will update continuously, keep yourself up to date 😉
5
star
23

MongoDb.Bugs

This repo reproduce some bugs of MongoDB C# Driver.
C#
3
star
24

SmartCachable.POC

C#
3
star
25

mjebrahimi

3
star
26

Pipeline-Filter-Pattern

Pipeline/Filter Pattern Implementation in C#
C#
3
star
27

Awesome-Viusal-Stuido-Extensions

Awesome Extensions for Viusal Stuido 2022
3
star
28

OpenTelemetry.Demo

C#
3
star
29

RazorPages_Bugs

Reproduce some bugs in ASP.NET Core Razor Pages.
C#
2
star
30

HybridCachePlayground

C#
1
star
31

DNZ.MvcComponents.Mvc5

Useful UI Html Helpers for ASP.NET MVC 5 from Popular JavaScript Plugins (Experimental project - Not maintained)
JavaScript
1
star