Get all values of a type from Redis

przemyslaw.szychowski
przemyslaw.szychowski Spryker Customer Posts: 9 🧑🏻‍🚀 - Cadet

Hi,

I need to read all merchants from the Redis in performant way.


I tried to use \Spryker\Client\Storage\StorageClientInterface::getKeys with kv:merchant:* wildcard , but it is blocking Redis, so whole system slows down.

I tried \Spryker\Client\Storage\StorageClientInterface::scanKeys as well, but it's too slow in big redis set.

Does the Spryker have any solution for that? Predis lib supports hash methods ( HSET, HGET, etc), but i don't see them in Spryker's wrapper of Predis.

Do you know any better or other solution to read all values of key subset (all merchants) from redis?

Best Answers

  • fsmeier
    fsmeier Senior Software Engineer & Developer Enablement Advocate Sprykee Posts: 1,056 ⚖️ - Guardians (admin)
    Answer ✓

    Heyhey,
    did you find a solution yet?

    If it works with the has methods you could expose them by overriding the RedisClient/RedisAdapter → vendor/spryker/redis/src/Spryker/Client/Redis/Adapter/PredisAdapter.php

    Also I saw that some redis methods (even within Spryker) offer pagination. Maybe this could also be a way to go.

    All the best,

    Florian

  • fsmeier
    fsmeier Senior Software Engineer & Developer Enablement Advocate Sprykee Posts: 1,056 ⚖️ - Guardians (admin)
    Answer ✓

    Hello @przemyslaw.szychowski ,

    ahh ok. No, sadly there is no OOTB solution I could find.

    All the best,

    Florian

Answers

  • ynnoig
    ynnoig Technical Lead eBusiness Spryker Customer Posts: 13 ✨ - Novice

    Why do u need to read all merchants from Redis?

  • przemyslaw.szychowski
    przemyslaw.szychowski Spryker Customer Posts: 9 🧑🏻‍🚀 - Cadet

    Merchants collection is just an example. We have such business case, which has to be fullfilled.

    At some cases it may be better to use ES for example, but we have a case, where we have a few dozen values of one type in Redis and easiest would be to just read them all at once instead of introducing ES or custom solution for that.

  • fsmeier
    fsmeier Senior Software Engineer & Developer Enablement Advocate Sprykee Posts: 1,056 ⚖️ - Guardians (admin)
    Answer ✓

    Heyhey,
    did you find a solution yet?

    If it works with the has methods you could expose them by overriding the RedisClient/RedisAdapter → vendor/spryker/redis/src/Spryker/Client/Redis/Adapter/PredisAdapter.php

    Also I saw that some redis methods (even within Spryker) offer pagination. Maybe this could also be a way to go.

    All the best,

    Florian

  • przemyslaw.szychowski
    przemyslaw.szychowski Spryker Customer Posts: 9 🧑🏻‍🚀 - Cadet

    Hello @fsmeier,

    thank you for responding my question.

    I know that these methods exist there and can be exposed, but this means extending a lot of Spryker's classes 😅

    I hoped there is some OOTB solution.

  • fsmeier
    fsmeier Senior Software Engineer & Developer Enablement Advocate Sprykee Posts: 1,056 ⚖️ - Guardians (admin)
    Answer ✓

    Hello @przemyslaw.szychowski ,

    ahh ok. No, sadly there is no OOTB solution I could find.

    All the best,

    Florian