Skip to content

Commit 4591e67

Browse files
authored
fix the memoryview: unsupported format <B error at redis connector (LMCache#662)
* [fix] fix the memoryview format, change form <B to B.
1 parent bb0222b commit 4591e67

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

lmcache/experimental/storage_backend/connector/redis_connector.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,6 @@ async def get(self, key: CacheEngineKey) -> Optional[MemoryObj]:
7575

7676
# TODO(Jiayi): Find a way to do `get` inplace
7777
kv_bytes = self.connection.get(key_str + "kv_bytes")
78-
7978
assert not inspect.isawaitable(kv_bytes)
8079

8180
if kv_bytes is None:
@@ -88,7 +87,12 @@ async def get(self, key: CacheEngineKey) -> Optional[MemoryObj]:
8887
self.connection.delete(key_str + "metadata")
8988
return None
9089

91-
view = memoryview(memory_obj.byte_array)
90+
if isinstance(memory_obj.byte_array, memoryview):
91+
view = memory_obj.byte_array
92+
if view.format == "<B":
93+
view = view.cast("B")
94+
else:
95+
view = memoryview(memory_obj.byte_array)
9296
view[:metadata.length] = kv_bytes
9397

9498
return memory_obj

0 commit comments

Comments
 (0)