Repository: aio-libs/aiocache

Issue:
Cache.REDIS: issubclass() arg 1 must be a class
In trying https://stackoverflow.com/questions/65686318/sharing-python-objects-across-multiple-workers I've encountered this exception.

Seems hit same issue here: https://github.com/samuelcolvin/pydantic/issues/545#issuecomment-595983173

From docker stderr:
```
app_1    |   File "/app/./main.py", line 8, in <module>
app_1    |     cache = Cache(Cache.REDIS, endpoint="localhost", port=6379, namespace="main")
app_1    |   File "/usr/local/lib/python3.8/site-packages/aiocache/factory.py", line 65, in __new__
app_1    |     assert issubclass(cache_class, BaseCache)
app_1    | TypeError: issubclass() arg 1 must be a class
```

REPL:

```
>>> from aiocache import Cache
ujson module not found, using json
msgpack not installed, MsgPackSerializer unavailable
>>> Cache()
<aiocache.backends.memory.SimpleMemoryCache object at 0x1085fd820>
>>> Cache(Cache.REDIS)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/variant23/repos/mintad-validator/venv/lib/python3.8/site-packages/aiocache/factory.py", line 65, in __new__
    assert issubclass(cache_class, BaseCache)
TypeError: issubclass() arg 1 must be a class
>>> type(Cache.REDIS)
<class 'NoneType'>
>>> print(Cache.REDIS)
None
>>> print(Cache.MEMORY)
<class 'aiocache.backends.memory.SimpleMemoryCache'>
```

Packages:

```
aiocache==0.11.1
fastapi==0.65.1
pydantic==1.8.2
```



Discussion:
codecov[bot]: ## [Codecov](https://app.codecov.io/gh/aio-libs/aiocache/pull/795?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=aio-libs) Report
All modified and coverable lines are covered by tests :white_check_mark:
> Comparison is base [(`a6a131e`)](https://app.codecov.io/gh/aio-libs/aiocache/commit/a6a131ecd33862a3406d03514e9e1031612301ef?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=aio-libs) 99.55% compared to head [(`6c39533`)](https://app.codecov.io/gh/aio-libs/aiocache/pull/795?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=aio-libs) 99.55%.

<details><summary>Additional details and impacted files</summary>


[![Impacted file tree graph](https://app.codecov.io/gh/aio-libs/aiocache/pull/795/graphs/tree.svg?width=650&height=150&src=pr&token=IjVDGI14Tx&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=aio-libs)](https://app.codecov.io/gh/aio-libs/aiocache/pull/795?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=aio-libs)

```diff
@@           Coverage Diff           @@
##             0.12     #795   +/-   ##
=======================================
  Coverage   99.55%   99.55%           
=======================================
  Files          35       35           
  Lines        3782     3783    +1     
=======================================
+ Hits         3765     3766    +1     
  Misses         17       17           
```

| [Flag](https://app.codecov.io/gh/aio-libs/aiocache/pull/795/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=aio-libs) | Coverage Δ | |
|---|---|---|
| [unit](https://app.codecov.io/gh/aio-libs/aiocache/pull/795/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=aio-libs) | `99.55% <100.00%> (+<0.01%)` | :arrow_up: |

Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=aio-libs#carryforward-flags-in-the-pull-request-comment) to find out more.

| [Files](https://app.codecov.io/gh/aio-libs/aiocache/pull/795?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=aio-libs) | Coverage Δ | |
|---|---|---|
| [aiocache/factory.py](https://app.codecov.io/gh/aio-libs/aiocache/pull/795?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=aio-libs#diff-YWlvY2FjaGUvZmFjdG9yeS5weQ==) | `100.00% <100.00%> (ø)` | |
| [tests/ut/test\_factory.py](https://app.codecov.io/gh/aio-libs/aiocache/pull/795?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=aio-libs#diff-dGVzdHMvdXQvdGVzdF9mYWN0b3J5LnB5) | `97.64% <100.00%> (+0.01%)` | :arrow_up: |

------

[Continue to review full report in Codecov by Sentry](https://app.codecov.io/gh/aio-libs/aiocache/pull/795?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=aio-libs).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=aio-libs)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://app.codecov.io/gh/aio-libs/aiocache/pull/795?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=aio-libs). Last update [a6a131e...6c39533](https://app.codecov.io/gh/aio-libs/aiocache/pull/795?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=aio-libs). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=aio-libs).

</details>

Patch:
diff --git a/aiocache/factory.py b/aiocache/factory.py
index 9ad2f98..ec674fd 100644
--- a/aiocache/factory.py
+++ b/aiocache/factory.py
@@ -60,7 +60,7 @@ class Cache:
     MEMCACHED = AIOCACHE_CACHES.get("memcached")
 
     def __new__(cls, cache_class=MEMORY, **kwargs):
-        if not issubclass(cache_class, BaseCache):
+        if not (cache_class and issubclass(cache_class, BaseCache)):
             raise InvalidCacheType(
                 "Invalid cache type, you can only use {}".format(list(AIOCACHE_CACHES.keys()))
             )


Test patch:
diff --git a/tests/ut/test_factory.py b/tests/ut/test_factory.py
index 56de47e..54120e9 100644
--- a/tests/ut/test_factory.py
+++ b/tests/ut/test_factory.py
@@ -74,9 +74,10 @@ class TestCache:
     def test_new_defaults_to_memory(self):
         assert isinstance(Cache(), Cache.MEMORY)
 
-    def test_new_invalid_cache_raises(self):
+    @pytest.mark.parametrize("cache_type", (None, object))
+    def test_new_invalid_cache_raises(self, cache_type):
         with pytest.raises(InvalidCacheType) as e:
-            Cache(object)
+            Cache(cache_type)
         assert str(e.value) == "Invalid cache type, you can only use {}".format(
             list(AIOCACHE_CACHES.keys())
         )