Beispiel #1
0
 def __init__(self,
              db_name: str,
              collection_name: str,
              connection: AsyncIOMotorClient = None,
              **kwargs):
     super().__init__(**kwargs)
     connection_kwargs = get_valid_kwargs(AsyncIOMotorClient.__init__,
                                          kwargs)
     self.connection = connection or AsyncIOMotorClient(**connection_kwargs)
     self.db = self.connection[db_name]
     self.collection = self.db[collection_name]
Beispiel #2
0
    def __init__(
        self, filename: str, table_name: str = 'aiohttp-cache', use_temp: bool = False, **kwargs
    ):
        super().__init__(**kwargs)
        self.connection_kwargs = get_valid_kwargs(sqlite_template, kwargs)
        self.filename = _get_cache_filename(filename, use_temp)
        self.table_name = table_name

        self._bulk_commit = False
        self._initialized = False
        self._connection = None
        self._lock = None
Beispiel #3
0
    def __init__(
        self,
        base_url: Optional[StrOrURL] = None,
        *,
        cache: CacheBackend = None,
        **kwargs,
    ):
        self.cache = cache or CacheBackend()

        # Pass along any valid kwargs for ClientSession (or custom session superclass)
        session_kwargs = get_valid_kwargs(super().__init__, {
            **kwargs, 'base_url': base_url
        })
        super().__init__(**session_kwargs)
Beispiel #4
0
 def __init__(
     self,
     namespace: str,
     collection_name: str,
     address: str = DEFAULT_ADDRESS,
     connection: Redis = None,
     **kwargs,
 ):
     # Pop off BaseCache kwargs and use the rest as Redis connection kwargs
     super().__init__(**kwargs)
     self.address = address
     self._connection = connection
     self.connection_kwargs = get_valid_kwargs(Connection.__init__, kwargs)
     self.hash_key = f'{namespace}:{collection_name}'
Beispiel #5
0
    def __init__(
        self,
        table_name: str,
        namespace: str,
        key_attr_name: str = 'k',
        val_attr_name: str = 'v',
        create_if_not_exists: bool = False,
        context: ResourceCreatorContext = None,
        **kwargs,
    ):
        super().__init__(**kwargs)
        self.table_name = table_name
        self.namespace = namespace
        self.key_attr_name = key_attr_name
        self.val_attr_name = val_attr_name
        self.create_if_not_exists = create_if_not_exists

        resource_kwargs = get_valid_kwargs(AWSSession.resource, kwargs)
        self.context = context or aioboto3.Session().resource(
            'dynamodb', **resource_kwargs)
        self._table = None