tarantool / ddl

The DDL module enables you to describe data schema in a declarative YAML-based format.
BSD 2-Clause "Simplified" License
12 stars 6 forks source link

Use cache for database schema in get_schema() #69

Open ligurio opened 3 years ago

ligurio commented 3 years ago

CRUD will use DDL schema to obtain a sharding key using get_schema(). However, on every get_schema() call DDL module scan spaces to build the current database schema. Need to cache a database schema.

Totktonada commented 3 years ago

Sadly, we have no public API for tracking a database schema version (without it there is no way to invalidate the cache, when some space or index is changed).

There is box.internal.schema_version(), which is obviously internal and has no guarantee that it'll exist in a future. It exists since 1.7.3-660-gcbfc235ee. We can take risks, use the internal function, file issue to expose it publicly (should be easy to implement and unlikely someone will be against). When it'll be exposed publicly, use the public function and fallback to the internal one if the public one does not exist.