Skip to content

Commit b26e3b0

Browse files
authored
3.12.4 updates (#361)
* Adding usePlanCache option for AQL queries. * Fixing Python 3.9 error * Dropping Python 3.8 support * Preparing new release * Adding errors script * Updating errors script * Updating docs * Removing errors script
1 parent 392390e commit b26e3b0

File tree

10 files changed

+548
-603
lines changed

10 files changed

+548
-603
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ database natively supporting documents, graphs and search.
2222
## Requirements
2323

2424
- ArangoDB version 3.11+
25-
- Python version 3.8+
25+
- Python version 3.9+
2626

2727
## Installation
2828

arango/aql.py

+37-2
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,36 @@ def response_handler(resp: Response) -> bool:
144144

145145
return self._execute(request, response_handler)
146146

147+
def plan_entries(self) -> Result[Jsons]:
148+
"""Return a list of all AQL query plan cache entries.
149+
150+
:return: List of AQL query plan cache entries.
151+
:rtype: list
152+
:raise arango.exceptions.AQLCacheEntriesError: If retrieval fails.
153+
"""
154+
request = Request(method="get", endpoint="/_api/query-plan-cache")
155+
156+
def response_handler(resp: Response) -> Jsons:
157+
if not resp.is_success:
158+
raise AQLCacheEntriesError(resp, request)
159+
result: Jsons = resp.body
160+
return result
161+
162+
return self._execute(request, response_handler)
163+
164+
def clear_plan(self) -> Result[None]:
165+
"""Clear the AQL query plan cache.
166+
167+
:raises arango.exceptions.AQLCacheClearError: If clearing the cache fails.
168+
"""
169+
request = Request(method="delete", endpoint="/_api/query-plan-cache")
170+
171+
def response_handler(resp: Response) -> None:
172+
if not resp.is_success:
173+
raise AQLCacheClearError(resp, request)
174+
175+
return self._execute(request, response_handler)
176+
147177

148178
class AQL(ApiGroup):
149179
"""AQL (ArangoDB Query Language) API wrapper.
@@ -277,6 +307,7 @@ def execute(
277307
allow_dirty_read: bool = False,
278308
allow_retry: bool = False,
279309
force_one_shard_attribute_value: Optional[str] = None,
310+
use_plan_cache: Optional[bool] = None,
280311
) -> Result[Cursor]:
281312
"""Execute the query and return the result cursor.
282313
@@ -388,6 +419,8 @@ def execute(
388419
shipped to a wrong DB server and may not return results
389420
(i.e. empty result set). Use at your own risk.
390421
:param force_one_shard_attribute_value: str | None
422+
:param use_plan_cache: If set to True, the query plan cache is used.
423+
:param use_plan_cache: bool | None
391424
:return: Result cursor.
392425
:rtype: arango.cursor.Cursor
393426
:raise arango.exceptions.AQLQueryExecuteError: If execute fails.
@@ -399,8 +432,6 @@ def execute(
399432
data["ttl"] = ttl
400433
if bind_vars is not None:
401434
data["bindVars"] = bind_vars
402-
if cache is not None:
403-
data["cache"] = cache
404435
if memory_limit is not None:
405436
data["memoryLimit"] = memory_limit
406437

@@ -437,6 +468,10 @@ def execute(
437468
options["allowRetry"] = allow_retry
438469
if force_one_shard_attribute_value is not None:
439470
options["forceOneShardAttributeValue"] = force_one_shard_attribute_value
471+
if cache is not None:
472+
options["cache"] = cache
473+
if use_plan_cache is not None:
474+
options["usePlanCache"] = use_plan_cache
440475

441476
if options:
442477
data["options"] = options

0 commit comments

Comments
 (0)