Skip to content

Commit

Permalink
Refactored Redis store
Browse files Browse the repository at this point in the history
  • Loading branch information
joachimmetz committed Apr 8, 2024
1 parent 42b2745 commit cbeb524
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 29 deletions.
4 changes: 4 additions & 0 deletions plaso/storage/redis/redis_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -453,6 +453,10 @@ def _WriteNewAttributeContainer(self, container):

if container.CONTAINER_TYPE == self._CONTAINER_TYPE_EVENT:
index_name = self._GetRedisHashName(self._EVENT_INDEX_NAME)

identifier = container.GetIdentifier()
redis_key = identifier.CopyToString()

self._redis_client.zincrby(index_name, container.timestamp, redis_key)

def GetAttributeContainerByIndex(self, container_type, index):
Expand Down
29 changes: 0 additions & 29 deletions tests/storage/redis/redis_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -329,35 +329,6 @@ def testGetNumberOfAttributeContainers(self):

self._RemoveSessionData(redis_client, session.identifier)

def testGetSerializedAttributeContainers(self):
"""Tests the GetSerializedAttributeContainers method."""
redis_client = self._CreateRedisClient()

session = sessions.Session()
task = tasks.Task(session_identifier=session.identifier)

test_store = redis_store.RedisAttributeContainerStore()
test_store.Open(
redis_client=redis_client, session_identifier=task.session_identifier,
task_identifier=task.identifier)

try:
for _, event_data, _ in containers_test_lib.CreateEventsFromValues(
self._TEST_EVENTS):
test_store.AddAttributeContainer(event_data)

cursor, serialized_containers = (
test_store.GetSerializedAttributeContainers('event_data', 0, 0))
self.assertEqual(len(serialized_containers), 4)
for serialized_container in serialized_containers:
self.assertIsInstance(serialized_container, bytes)
self.assertIsInstance(cursor, int)

finally:
test_store.Close()

self._RemoveSessionData(redis_client, session.identifier)

def testGetSortedEvents(self):
"""Tests the GetSortedEvents method."""
redis_client = self._CreateRedisClient()
Expand Down

0 comments on commit cbeb524

Please sign in to comment.