JSONAPI-Resources / JSONAPI-Resources/jsonapi-resources
Caching not working with RedisStore Cache
Nadie ha tomado este issue todavía.
- Lenguaje dominante
- Ruby
- Estrellas
- 2.3k
- Forks
- 546
- Métricas de merge de PR
- Sin PR fusionados en 30 d
Descripción
Using Rails.cache as a resource_cache appears to make the caching fail when config.cache_store is redis_store.
I think the reason is due to the way Redis Cache serialise key as string when they are arrays.
When the key(an array) is serialised in the self.write method of CachedResourceFragment
https://github.com/cerebris/jsonapi-resources/blob/master/lib/jsonapi/cached_resource_fragment.rb#L122 it is serialised as a string.
When the value is retrieved in the lookup method the hash hits returned by the read_multi methods has keys that are not array, but strings. The method has_key? is then failing returning false instead of true.
https://github.com/cerebris/jsonapi-resources/blob/master/lib/jsonapi/cached_resource_fragment.rb#L81
Simple example, with config.cache_store = :redis_store
Rails.cache.write([1,2], 'value')
hash = Rails.cache.read_multi([1,2])
# returns false
hash.has_key?([1,2])
I've tried to serialise manually the keys (https://github.com/cerebris/jsonapi-resources/compare/master...x4d3:master) without success, the test are failing.
Thank you,
Guía de contribución
No hay ninguna guía de contribución indexada para este repositorio
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Línea de trabajo
Empieza en lib/jsonapi/cached_resource_fragment.rb, en lookup y self.write, y luego reproduce el ejemplo de Rails.cache.read_multi con config.cache_store establecido en :redis_store. Compara los tipos de clave devueltos por RedisStore con las claves de array utilizadas por has_key?; la tarea estará terminada cuando se reconozcan los aciertos de caché y pasen las pruebas existentes.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- rails, redis, ruby
- Área
- backend, performance
- Tipo de issue
- Error
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Estado de actividad
- Estancado
- Claridad
- Bastante claro
- Aptitud para principiantes
- 38/100