FLUSHDB [ASYNC] * * Flushes the currently SELECTed Redis DB. */
| 829 | * |
| 830 | * Flushes the currently SELECTed Redis DB. */ |
| 831 | void flushdbCommand(client *c) { |
| 832 | int flags; |
| 833 | |
| 834 | if (c->argc == 2) |
| 835 | { |
| 836 | if (!strcasecmp(szFromObj(c->argv[1]), "cache")) |
| 837 | { |
| 838 | if (g_pserver->m_pstorageFactory == nullptr) |
| 839 | { |
| 840 | addReplyError(c, "Cannot flush cache without a storage provider set"); |
| 841 | return; |
| 842 | } |
| 843 | c->db->removeAllCachedValues(); |
| 844 | addReply(c,shared.ok); |
| 845 | return; |
| 846 | } |
| 847 | } |
| 848 | |
| 849 | if (getFlushCommandFlags(c,&flags) == C_ERR) return; |
| 850 | g_pserver->dirty += emptyDb(c->db->id,flags,NULL); |
| 851 | addReply(c,shared.ok); |
| 852 | #if defined(USE_JEMALLOC) |
| 853 | /* jemalloc 5 doesn't release pages back to the OS when there's no traffic. |
| 854 | * for large databases, flushdb blocks for long anyway, so a bit more won't |
| 855 | * harm and this way the flush and purge will be synchroneus. */ |
| 856 | if (!(flags & EMPTYDB_ASYNC)) |
| 857 | jemalloc_purge(); |
| 858 | #endif |
| 859 | } |
| 860 | |
| 861 | /* FLUSHALL [ASYNC] |
| 862 | * |
nothing calls this directly
no test coverage detected