Code Monkey home page Code Monkey logo

Comments (8)

harlowja avatar harlowja commented on May 27, 2024

What python library provides all of those?

from pymemcache.

sontek avatar sontek commented on May 27, 2024

You don't need a single python library for them. i.e if you allow this:

class ICompressable:
    def compress(obj):
        pass
    def decompress(obj):
        pass

and on the client you accept a compressor argument:

from pymemcache import Client
import lz4

class LZ4Compressor:
    def compress(obj):
        return lz4.dumps(obj)

    def decompress(obj):
        return lz4.loads(obj)

client = Client(compressor=lzr_compressor)

from pymemcache.

harlowja avatar harlowja commented on May 27, 2024

Fair enough that works to.

from pymemcache.

sontek avatar sontek commented on May 27, 2024

Only thing would be if we wanted to flag each type of compressor in the data that way if you had two clients:

client = Client(compressor=lz4_compressor)
client2 = Client(compressor=speedy_compressor)

If client1 tried to open a key from client2 it would fail. Would we want to detect its using a different compressor and raise a nice error like "Hey, that key was compressed with lz4!" or do we just blow up with a weird error and let them figure it out?

If we wanted to provide the nice flags then we'd have to maintain them internally like:

FLAG_LZ4 = 1 << 3
FLAG_SPEEDY = 1 <<  4
FLAG_ZLIB = 1 << 5

from pymemcache.

akatrevorjay avatar akatrevorjay commented on May 27, 2024

I put up a refactor branch to help with this in #160 and #161 along with a json codec. I wrote something similar for my own projects in the past, so it was mostly copypasta from that. I need to dig deeper but I also have a pipeline that would be helpful in this case, ie compression. We can just pass the bitflags in modified, that's at least what I did in the past.

from pymemcache.

sirosen avatar sirosen commented on May 27, 2024

You can now implement this in 3.0 with a custom serde object which makes these decisions.
(You can do it in 2.x with serializer/deserializer too.)

@jogo, @jparise, should this be kept open? If so, the issue would seem to be adding built-in support for compression -- e.g. a built-in PickleZlibSerde.

from pymemcache.

jparise avatar jparise commented on May 27, 2024

I think we could emphasize the fact that the serde interface is the place to implement (de)compression (or other data transformations). I don't think pymemcache needs to provide compression implementations itself.

from pymemcache.

jparise avatar jparise commented on May 27, 2024

Closing this because this functionality is now available through the serde object interface.

from pymemcache.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.