Skip to content

Custom codecs #122

@supun-kanda

Description

@supun-kanda

There's lack of documentation on custom codecs and storing Non-string type values on redis.

In my use case here are the formats
key type: String
value type: CustomPoJo

I tried the following ways to add my own value type

redis:
  type: basic
  name: my-redis-use-case
  node:
    type: redis
    node: "localhost:6379"
    clientName: redis-primary
  redisCodec:
    type: compression
    compressionType: GZIP
    delegatee:
      type: com.supun.cache.codec.GoogleCodec
  clientResources:
    type: default
    commandLatencyCollector:
      type: default
      enabled: false

where The GoogleCodec is a subclass of RedisCodec and is the same type references as the application key-value pair

The other way is to simply give the custom Codec as the type

redis:
  type: basic
  name: my-redis-use-case
  node:
    type: redis
    node: "localhost:6379"
    clientName: redis-primary
  redisCodec:
    type: com.supun.cache.codec.GoogleCodec
  clientResources:
    type: default
    commandLatencyCollector:
      type: default
      enabled: false

In both cases, it failed to identify the custom codec. And gives the following errors.

  • for case 1,
* Failed to parse configuration at: redis.redisCodec; Could not resolve type id 'com.supun.msod.cache.codec.GoogleCodec' into a subtype of [simple type, class io.dropwizard.redis.codec.RedisCodecFactory<java.lang.String,com.supun.api.gbp.GoogleCacheToken>]: known type ids = [RedisCodecFactory, byte-array, compression, string, utf8-string]
 at [Source: N/A; line: -1, column: -1] (through reference chain: com.supun.MsodConfiguration["redis"]->io.dropwizard.redis.RedisClientFactory["redisCodec"])
  • for case 2
* Failed to parse configuration at: redis.redisCodec.delegatee; Could not resolve type id 'com.supun.cache.codec.GoogleCodec' into a subtype of [simple type, class io.dropwizard.redis.codec.RedisCodecFactory<java.lang.String,com.supun.api.gbp.GoogleCacheToken>]: known type ids = [RedisCodecFactory, byte-array, compression, string, utf8-string]
 at [Source: N/A; line: -1, column: -1] (through reference chain: com.supun.MsodConfiguration["redis"]->io.dropwizard.redis.RedisClientFactory["redisCodec"]->io.dropwizard.redis.codec.CompressionCodecFactory["delegatee"])

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions