2017-05-27 19:03:27 +02:00
|
|
|
import collections
|
|
|
|
|
|
|
|
InventoryItem = collections.namedtuple('InventoryItem', 'type stream payload expires tag')
|
|
|
|
|
|
|
|
class Storage(object):
|
2019-09-24 11:20:20 +02:00
|
|
|
"""Base class for storing inventory (extendable for other items to store)"""
|
2017-05-27 19:03:27 +02:00
|
|
|
pass
|
|
|
|
# def __init__(self):
|
|
|
|
# super(self.__class__, self).__init__()
|
|
|
|
|
|
|
|
class InventoryStorage(Storage, collections.MutableMapping):
|
|
|
|
def __init__(self):
|
|
|
|
# super(self.__class__, self).__init__()
|
|
|
|
self.numberOfInventoryLookupsPerformed = 0
|
|
|
|
|
|
|
|
def __contains__(self, hash):
|
|
|
|
raise NotImplementedError
|
|
|
|
|
|
|
|
def __getitem__(self, hash):
|
|
|
|
raise NotImplementedError
|
|
|
|
|
|
|
|
def __setitem__(self, hash, value):
|
|
|
|
raise NotImplementedError
|
|
|
|
|
|
|
|
def __delitem__(self, hash):
|
|
|
|
raise NotImplementedError
|
|
|
|
|
|
|
|
def __iter__(self):
|
|
|
|
raise NotImplementedError
|
|
|
|
|
|
|
|
def __len__(self):
|
|
|
|
raise NotImplementedError
|
|
|
|
|
2017-06-24 12:13:35 +02:00
|
|
|
def by_type_and_tag(self, objectType, tag):
|
2019-09-24 11:20:20 +02:00
|
|
|
"""Return objects filtered by object type and tag"""
|
2017-05-27 19:03:27 +02:00
|
|
|
raise NotImplementedError
|
|
|
|
|
|
|
|
def unexpired_hashes_by_stream(self, stream):
|
2019-09-24 11:20:20 +02:00
|
|
|
"""Return unexpired inventory vectors filtered by stream"""
|
2017-05-27 19:03:27 +02:00
|
|
|
raise NotImplementedError
|
|
|
|
|
|
|
|
def flush(self):
|
2019-09-24 11:20:20 +02:00
|
|
|
"""Flush cache"""
|
2017-05-27 19:03:27 +02:00
|
|
|
raise NotImplementedError
|
|
|
|
|
|
|
|
def clean(self):
|
2019-09-24 11:20:20 +02:00
|
|
|
"""Free memory / perform garbage collection"""
|
2017-05-27 19:03:27 +02:00
|
|
|
raise NotImplementedError
|
|
|
|
|
|
|
|
class MailboxStorage(Storage, collections.MutableMapping):
|
|
|
|
def __init__(self):
|
|
|
|
# super(self.__class__, self).__init__()
|
|
|
|
pass
|