MCPcopy Create free account
hub / github.com/Tencent/MMKV / getDataWithoutMTimeForKey

Method getDataWithoutMTimeForKey

Core/MMKV_IO.cpp:1984–2016  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1982}
1983
1984mmkv::MMBuffer MMKV::getDataWithoutMTimeForKey(MMKVKey_t key) {
1985 SCOPED_LOCK(m_lock);
1986 SCOPED_LOCK(m_sharedProcessLock);
1987 checkLoadData();
1988
1989 auto raw = getRawDataForKey(key);
1990 assert(raw.length() == 0 || raw.length() >= Fixed32Size);
1991 if (raw.length() < Fixed32Size) {
1992 if (raw.length() != 0) {
1993#ifdef MMKV_APPLE
1994 MMKVWarning("key [%@] has invalid value size %u", key, raw.length());
1995#else
1996 MMKVWarning("key [%s] has invalid value size %u", key.data(), raw.length());
1997#endif
1998 }
1999 return raw;
2000 }
2001 auto newLength = raw.length() - Fixed32Size;
2002 if (m_enableKeyExpire) {
2003 auto ptr = (const uint8_t *) raw.getPtr() + newLength;
2004 auto time = *(const uint32_t *) ptr;
2005 if (time != ExpireNever && time <= getCurrentTimeInSecond()) {
2006#ifdef MMKV_APPLE
2007 MMKVInfo("deleting expired key [%@] in mmkv [%s], due date %u", key, m_mmapID.c_str(), time);
2008#else
2009 MMKVInfo("deleting expired key [%s] in mmkv [%s], due date %u", key.data(), m_mmapID.c_str(), time);
2010#endif
2011 removeValueForKey(key);
2012 return MMBuffer();
2013 }
2014 }
2015 return MMBuffer(std::move(raw), newLength);
2016}
2017
2018#define NOOP ((void) 0)
2019

Callers

nothing calls this directly

Calls 2

MMBufferFunction · 0.70
removeValueForKeyFunction · 0.50

Tested by

no test coverage detected