>> I have no problem in the development of the application, my problem is
>> the structure of the data in redis. The best and optimization, because
>> I lack knowledge even redis.
If you have additional data to associate to the prefix, you can easily adapt
the solution given by Dvir and Josiah by using a hash instead of a set.
You need one hash object per supplier, plus one hash to index all prefixes.
Example:
# Here are my suppliers
> ./redis-cli hmset supplier:1 prefix 5690 supplier Apple price expensive active Y description iJunk
OK
> ./redis-cli hmset supplier:2 prefix 569080 supplier Acer price cheap active Y description junk
OK
# Here is the index of prefixes, which I need to maintain each time I add/delete suppliers
> ./redis-cli hmset prefix 5690 1 569080 2
OK
# To check a given number, generate all sub-prefixes starting by the end (as explained by Dvir and Josiah)
# and check their existence in one rountrip
# Here I check 5690801
> ./redis-cli hmget prefix 5690801 569080 56908 5690 569 56 5
1) (nil)
2) "2"
3) (nil)
4) "1"
5) (nil)
6) (nil)
7) (nil)
Form the result, you can easily find the record you are interested in
(take the first non null result).
# Then, you just have to retrieve the properties of the corresponding supplier
> ./redis-cli hgetall supplier:2
1) "prefix"
2) "569080"
3) "supplier"
4) "Acer"
5) "price"
6) "cheap"
7) "active"
8) "Y"
9) "description"
10) "junk"
Regards,
Didier.