summaryrefslogtreecommitdiff
path: root/ext/cache
diff options
context:
space:
mode:
Diffstat (limited to 'ext/cache')
-rw-r--r--ext/cache/sqlite.rs13
1 files changed, 7 insertions, 6 deletions
diff --git a/ext/cache/sqlite.rs b/ext/cache/sqlite.rs
index 2853f793d..4eb9924c7 100644
--- a/ext/cache/sqlite.rs
+++ b/ext/cache/sqlite.rs
@@ -10,6 +10,7 @@ use std::time::UNIX_EPOCH;
use async_trait::async_trait;
use deno_core::error::AnyError;
use deno_core::parking_lot::Mutex;
+use deno_core::task::spawn_blocking;
use deno_core::AsyncRefCell;
use deno_core::AsyncResult;
use deno_core::ByteString;
@@ -99,7 +100,7 @@ impl Cache for SqliteBackedCache {
async fn storage_open(&self, cache_name: String) -> Result<i64, AnyError> {
let db = self.connection.clone();
let cache_storage_dir = self.cache_storage_dir.clone();
- tokio::task::spawn_blocking(move || {
+ spawn_blocking(move || {
let db = db.lock();
db.execute(
"INSERT OR IGNORE INTO cache_storage (cache_name) VALUES (?1)",
@@ -124,7 +125,7 @@ impl Cache for SqliteBackedCache {
/// Note: this doesn't check the disk, it only checks the sqlite db.
async fn storage_has(&self, cache_name: String) -> Result<bool, AnyError> {
let db = self.connection.clone();
- tokio::task::spawn_blocking(move || {
+ spawn_blocking(move || {
let db = db.lock();
let cache_exists = db.query_row(
"SELECT count(id) FROM cache_storage WHERE cache_name = ?1",
@@ -143,7 +144,7 @@ impl Cache for SqliteBackedCache {
async fn storage_delete(&self, cache_name: String) -> Result<bool, AnyError> {
let db = self.connection.clone();
let cache_storage_dir = self.cache_storage_dir.clone();
- tokio::task::spawn_blocking(move || {
+ spawn_blocking(move || {
let db = db.lock();
let maybe_cache_id = db
.query_row(
@@ -210,7 +211,7 @@ impl Cache for SqliteBackedCache {
> {
let db = self.connection.clone();
let cache_storage_dir = self.cache_storage_dir.clone();
- let query_result = tokio::task::spawn_blocking(move || {
+ let query_result = spawn_blocking(move || {
let db = db.lock();
let result = db.query_row(
"SELECT response_body_key, response_headers, response_status, response_status_text, request_headers
@@ -269,7 +270,7 @@ impl Cache for SqliteBackedCache {
request: CacheDeleteRequest,
) -> Result<bool, AnyError> {
let db = self.connection.clone();
- tokio::task::spawn_blocking(move || {
+ spawn_blocking(move || {
// TODO(@satyarohith): remove the response body from disk if one exists
let db = db.lock();
let rows_effected = db.execute(
@@ -287,7 +288,7 @@ async fn insert_cache_asset(
put: CachePutRequest,
response_body_key: Option<String>,
) -> Result<Option<String>, deno_core::anyhow::Error> {
- tokio::task::spawn_blocking(move || {
+ spawn_blocking(move || {
let maybe_response_body = {
let db = db.lock();
db.query_row(