'Get the media_id and ts for a cached URL as of the given timestamp
Returns:
None if the URL isn\'t cached.'

def get_url_cache(self, url, ts):

    def get_url_cache_txn(txn):
        sql = 'SELECT    response_code,    etag,    expires,    og,    media_id,    download_ts    FROM    local_media_repository_url_cache    WHERE    url    =    ?    AND    download_ts    <=    ?    ORDER    BY    download_ts    DESC    LIMIT    1'
        txn.execute(sql, (url, ts))
        row = txn.fetchone()
        if (not row):
            sql = 'SELECT    response_code,    etag,    expires,    og,    media_id,    download_ts    FROM    local_media_repository_url_cache    WHERE    url    =    ?    AND    download_ts    >    ?    ORDER    BY    download_ts    ASC    LIMIT    1'
            txn.execute(sql, (url, ts))
            row = txn.fetchone()
        if (not row):
            return None
        return dict(zip(('response_code', 'etag', 'expires', 'og', 'media_id', 'download_ts'), row))
    return self.runInteraction('get_url_cache', get_url_cache_txn)
