| 961 | } |
| 962 | |
| 963 | bool redisDbPersistentData::iterate(std::function<bool(const char*, robj*)> fn) |
| 964 | { |
| 965 | dictIterator *di = dictGetSafeIterator(m_pdict); |
| 966 | dictEntry *de = nullptr; |
| 967 | bool fResult = true; |
| 968 | while(fResult && ((de = dictNext(di)) != nullptr)) |
| 969 | { |
| 970 | if (!fn((const char*)dictGetKey(de), (robj*)dictGetVal(de))) |
| 971 | fResult = false; |
| 972 | } |
| 973 | dictReleaseIterator(di); |
| 974 | |
| 975 | if (m_spstorage != nullptr) |
| 976 | { |
| 977 | bool fSawAll = fResult && m_spstorage->enumerate([&](const char *key, size_t cchKey, const void *, size_t )->bool{ |
| 978 | sds sdsKey = sdsnewlen(key, cchKey); |
| 979 | bool fContinue = true; |
| 980 | if (dictFind(m_pdict, sdsKey) == nullptr) |
| 981 | { |
| 982 | ensure(sdsKey, &de); |
| 983 | fContinue = fn((const char*)dictGetKey(de), (robj*)dictGetVal(de)); |
| 984 | removeCachedValue(sdsKey); |
| 985 | } |
| 986 | sdsfree(sdsKey); |
| 987 | return fContinue; |
| 988 | }); |
| 989 | return fSawAll; |
| 990 | } |
| 991 | |
| 992 | if (fResult && m_pdbSnapshot != nullptr) |
| 993 | { |
| 994 | fResult = m_pdbSnapshot->iterate_threadsafe([&](const char *key, robj_roptr){ |
| 995 | // Before passing off to the user we need to make sure it's not already in the |
| 996 | // the current set, and not deleted |
| 997 | dictEntry *deCurrent = dictFind(m_pdict, key); |
| 998 | if (deCurrent != nullptr) |
| 999 | return true; |
| 1000 | dictEntry *deTombstone = dictFind(m_pdictTombstone, key); |
| 1001 | if (deTombstone != nullptr) |
| 1002 | return true; |
| 1003 | |
| 1004 | // Alright it's a key in the use keyspace, lets ensure it and then pass it off |
| 1005 | ensure(key); |
| 1006 | deCurrent = dictFind(m_pdict, key); |
| 1007 | return fn(key, (robj*)dictGetVal(deCurrent)); |
| 1008 | }, true /*fKeyOnly*/); |
| 1009 | } |
| 1010 | |
| 1011 | return fResult; |
| 1012 | } |
| 1013 | |
| 1014 | client *createAOFClient(void); |
| 1015 | void freeFakeClient(client *); |
no test coverage detected