Commit 95a53e48 authored by mashony's avatar mashony
Browse files

fix: change timestamp usage while caching serialized data

parent 833c511d
......@@ -81,4 +81,6 @@ venv/
*.swp
*/*.swp
*/*/*.swp
*/*/*/*.swp
\ No newline at end of file
*/*/*/*.swp
**/*.db
......@@ -31,4 +31,6 @@ MANIFEST
__pycache__
.coverage*
cover-html
specs*
\ No newline at end of file
specs*
**/*.db
......@@ -104,7 +104,7 @@ class MongoDBMirror:
elif entry['ns'] != client.namespace:
continue
elif op == MongoOperation.INSERT:
data = await self._get_serialized_document(data, collection, timestamp)
data = await self._get_serialized_document(data, collection, entry['ts'])
await client.upsert(ts, data)
elif op == MongoOperation.UPDATE:
if '$v' in data:
......@@ -114,7 +114,7 @@ class MongoDBMirror:
if data is None:
LOG.warning(f'Document not found: {collection} with {entry["o2"]["_id"]}')
continue
data = await self._get_serialized_document(data, collection, timestamp)
data = await self._get_serialized_document(data, collection, entry['ts'])
await client.upsert(ts, data)
elif op == MongoOperation.DELETE:
data = self._serialize_data(data)
......@@ -153,7 +153,7 @@ class MongoDBMirror:
async def _get_serialized_document(self, data, collection, timestamp):
_obj_id = data.get('_id', '')
cache_key = f"{timestamp.time}_{_obj_id}"
cache_key = f"{timestamp.time}_{timestamp.inc}_{_obj_id}"
loop = asyncio.get_running_loop()
try:
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment