All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.jfinal.plugin.redis.serializer.FurySerializer Maven / Gradle / Ivy

Go to download

JFinal is a simple, light, rapid,independent, extensible Java WEB + ORM framework. The feature of JFinal looks like ruby on rails especially ActiveRecord.

There is a newer version: 5.2.3
Show newest version
package com.jfinal.plugin.redis.serializer;

import io.fury.Fury;
import io.fury.ThreadSafeFury;
import io.fury.config.Language;
import redis.clients.jedis.util.SafeEncoder;

/**
 * FurySerializer
 */
public class FurySerializer implements ISerializer {

    public static final ISerializer me = new FurySerializer();

    private static ThreadSafeFury fury;

    static {
        fury = Fury.builder()
                .withLanguage(Language.JAVA)
                .withRefTracking(true)
                .requireClassRegistration(false)
                .withNumberCompressed(false)
                // .withAsyncCompilation(true)
                .buildThreadSafeFury();
                // .withCompatibleMode(CompatibleMode.SCHEMA_CONSISTENT)
                // .buildThreadSafeFuryPool(8, 32, 5, TimeUnit.MINUTES);
                // .buildThreadLocalFury();
    }

    @Override
    public byte[] keyToBytes(String key) {
        return SafeEncoder.encode(key);
    }

    @Override
    public String keyFromBytes(byte[] bytes) {
        return SafeEncoder.encode(bytes);
    }

    @Override
    public byte[] fieldToBytes(Object field) {
        return SafeEncoder.encode(field.toString());
    }

    @Override
    public Object fieldFromBytes(byte[] bytes) {
        return SafeEncoder.encode(bytes);
    }

    @Override
    public byte[] valueToBytes(Object value) {
        return fury.serialize(value);
    }

    @Override
    public Object valueFromBytes(byte[] bytes) {
        return bytes != null ? fury.deserialize(bytes) : null;
    }
}





© 2015 - 2025 Weber Informatics LLC | Privacy Policy