Skip to content

Commit 21e7478

Browse files
committed
change class docs
1 parent 93eb908 commit 21e7478

File tree

1 file changed

+7
-10
lines changed

1 file changed

+7
-10
lines changed

cacheref/cache.py

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -195,8 +195,8 @@ def __call__(
195195
Main decorator that caches function results.
196196
197197
Args:
198-
entity: The primary entity type this function deals with. Can be:
199-
- String: Entity type name (e.g., 'user', 'product')
198+
entity: The entity type that appears in this function's results, used for later invalidations. Can be:
199+
- String: Entity tagged name (e.g., 'user', 'product')
200200
- Class: SQLAlchemy or Django ORM model class (e.g., User, Product)
201201
Used for cache invalidation when entities of this type are modified.
202202
id_key: How to extract entity IDs from function results for cache invalidation.
@@ -206,8 +206,8 @@ def __call__(
206206
- Tuple of (str, callable): tries string access first, falls back to callable
207207
Default is 'id'. If entity is an ORM model class, this is automatically set
208208
to extract the primary key from model instances.
209-
cache_key: Optional custom key prefix for the cache to unify caching
210-
across services or functions. If not provided, uses function name.
209+
cache_key: Optional overridden custom key prefix for the cache to unify caching
210+
across services or functions. If not provided, we use function name + args.
211211
normalize_args: Whether to normalize argument values (sorts lists/dicts) for consistent
212212
cache keys across different argument orders. Set to True when
213213
cache key consistency is important across different services.
@@ -217,9 +217,7 @@ def __call__(
217217
Default: (str, int, UUID). Strongly recommended to use the
218218
global_supported_id_types instance parameter instead of
219219
overriding per function.
220-
scope (deprecated): Determines the scope of cache sharing, with two possible values:
221-
- 'function' (default): Function first caching with no cache sharing between same entity signatures
222-
- 'entity': Entity first caching - different functions with same entity and arguments share cache
220+
scope (deprecated): Determines the scope of cache sharing. Not used in this version.
223221
serializer: Custom function to serialize data before caching. If not provided, uses the default
224222
serializer set on the cache instance.
225223
deserialize: Custom function to deserialize cached data. If not provided, uses the default deserializer
@@ -247,9 +245,8 @@ def __call__(
247245
effective_id_key = extractor(entity)
248246
logger.debug(f"Using ORM extractor for {entity_name} model")
249247
except (ImportError, ValueError) as e:
250-
# If ORM support fails, fall back to using class name
251-
logger.warning(f"ORM detection failed: {e}. Using class name as entity.")
252-
effective_entity = entity.__name__.lower()
248+
# If ORM support fails, raise an error
249+
raise ValueError(f"ORM detection failed: {e}. Using class name as entity.")
253250

254251
supported_id_types = supported_id_types or self.supported_primitive_id_types
255252
# if didn't detect ORM model, use entity as is

0 commit comments

Comments
 (0)