Repository: litestar-org/litestar

Issue:
StaticFilesConfig and virtual directories
I'm trying to write a ``FileSystemProtocol`` to load files from the package data using [importlib_resources](https://importlib-resources.readthedocs.io/en/latest/using.html#). But because ``directories`` is defined as ``DirectoryPath``, pydantic checks if the given directories exist in the local filesystem. 

This is not generally true, especially in any kind of virtual filesystem (e.g. a zipped package). I think this condition should be relaxed to support virtual filesystems.

https://github.com/starlite-api/starlite/blob/9bb6dcd57c10a591377cf8e3a537e9292566d5b9/starlite/config/static_files.py#L32


Discussion:
I agree. Do you want to submit a PR?

Resolving patch:
diff --git a/docs/examples/stores/registry_configure_integrations.py b/docs/examples/stores/registry_configure_integrations.py
--- a/docs/examples/stores/registry_configure_integrations.py
+++ b/docs/examples/stores/registry_configure_integrations.py
@@ -8,7 +8,7 @@
 app = Starlite(
     stores={
         "sessions": RedisStore.with_client(),
-        "request_cache": FileStore(Path("request-cache")),
+        "response_cache": FileStore(Path("response-cache")),
     },
     middleware=[ServerSideSessionConfig().middleware],
 )
diff --git a/docs/examples/stores/registry_default_factory_namespacing.py b/docs/examples/stores/registry_default_factory_namespacing.py
--- a/docs/examples/stores/registry_default_factory_namespacing.py
+++ b/docs/examples/stores/registry_default_factory_namespacing.py
@@ -9,7 +9,7 @@
 
 @get(cache=True)
 def cached_handler() -> str:
-    # this will use app.stores.get("request_cache")
+    # this will use app.stores.get("response_cache")
     return "Hello, world!"
 
 
diff --git a/starlite/config/response_cache.py b/starlite/config/response_cache.py
--- a/starlite/config/response_cache.py
+++ b/starlite/config/response_cache.py
@@ -40,7 +40,7 @@ class ResponseCacheConfig:
     """Default cache expiration in seconds."""
     key_builder: CacheKeyBuilder = field(default=default_cache_key_builder)
     """:class:`CacheKeyBuilder <.types.CacheKeyBuilder>`. Defaults to :func:`default_cache_key_builder`."""
-    store: str = "request_cache"
+    store: str = "response_cache"
     """Name of the :class:`Store <.stores.base.Store>` to use."""
 
     def get_store_from_app(self, app: Starlite) -> Store:


Test patch:
diff --git a/docs/examples/tests/test_stores.py b/docs/examples/tests/test_stores.py
--- a/docs/examples/tests/test_stores.py
+++ b/docs/examples/tests/test_stores.py
@@ -97,7 +97,7 @@ async def test_configure_integrations(mock_redis: MagicMock) -> None:
 
     assert isinstance(session_store, RedisStore)
     assert isinstance(cache_store, FileStore)
-    assert cache_store.path == Path("request-cache")
+    assert cache_store.path == Path("response-cache")
 
 
 async def test_registry_default_factory() -> None:
diff --git a/tests/test_response_caching.py b/tests/test_response_caching.py
--- a/tests/test_response_caching.py
+++ b/tests/test_response_caching.py
@@ -101,7 +101,7 @@ async def handler() -> str:
 
     with TestClient(app) as client:
         client.get("/cached")
-        store = app.stores.get("request_cache")
+        store = app.stores.get("response_cache")
         assert await store.exists("/cached:::cached")
 
 
@@ -131,7 +131,7 @@ async def test_with_stores(store: Store, mock: MagicMock) -> None:
     def handler() -> str:
         return mock()  # type: ignore[no-any-return]
 
-    app = Starlite([handler], stores={"request_cache": store})
+    app = Starlite([handler], stores={"response_cache": store})
 
     with TestClient(app=app) as client:
         response_one = client.get("/")