Changeset View
Changeset View
Standalone View
Standalone View
swh/scheduler/updater/backend.py
Show First 20 Lines • Show All 66 Lines • ▼ Show 20 Lines | def cache_read(self, timestamp=None, limit=None, db=None, cur=None): | ||||
timestamp = utcnow() | timestamp = utcnow() | ||||
if not limit: | if not limit: | ||||
limit = self.limit | limit = self.limit | ||||
q = format_query('select {keys} from swh_cache_read(%s, %s)', | q = format_query('select {keys} from swh_cache_read(%s, %s)', | ||||
self.cache_read_keys) | self.cache_read_keys) | ||||
cur.execute(q, (timestamp, limit)) | cur.execute(q, (timestamp, limit)) | ||||
for r in cur.fetchall(): | yield from cur.fetchall() | ||||
r['id'] = r['id'].tobytes() | |||||
yield r | |||||
@db_transaction() | @db_transaction() | ||||
def cache_remove(self, entries, db=None, cur=None): | def cache_remove(self, entries, db=None, cur=None): | ||||
"""Clean events from the cache | """Clean events from the cache | ||||
""" | """ | ||||
q = 'delete from cache where url in (%s)' % ( | q = 'delete from cache where url in (%s)' % ( | ||||
', '.join(("'%s'" % e for e in entries)), ) | ', '.join(("'%s'" % e for e in entries)), ) | ||||
Show All 26 Lines |