JSONAPI-Resources / JSONAPI-Resources/jsonapi-resources
Caching not working with RedisStore Cache
Nessuno ha ancora preso questa issue.
- Lingua principale
- Ruby
- Stelle
- 2.3k
- Fork
- 546
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Descrizione
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,
Guida per i contributori
Nessuna guida per i contributori indicizzata per questo repository
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
Inizia in lib/jsonapi/cached_resource_fragment.rb, in lookup e self.write, quindi riproduci l’esempio di Rails.cache.read_multi con config.cache_store impostato su :redis_store. Confronta i tipi di chiave restituiti da RedisStore con le chiavi di array utilizzate da has_key?; il lavoro è completato quando i riscontri nella cache vengono riconosciuti e i test esistenti hanno esito positivo.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- rails, redis, ruby
- Ambito
- backend, performance
- Tipo di issue
- Bug
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 38/100