validators
validate_cache(cache=None, none_ok=True)
Validate a DiskCache cache object.
Checks for existence and correct type.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
cache |
Cache
|
A |
None
|
none_ok |
bool
|
Allow null values |
True
|
Returns:
| Type | Description |
|---|---|
Cache
|
The original |
Source code in src/red_utils/ext/diskcache_utils/validators.py
validate_expire(expire=None, none_ok=False)
Validate input diskcache expiration time.
Only int types allowed. Expiration time is in seconds.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
expire |
int
|
The amount of seconds for an expiration value |
None
|
none_ok |
bool
|
none_ok (bool): Allow null values |
False
|
Returns:
| Type | Description |
|---|---|
int
|
The original expiration time (in seconds) if validation passes |
Source code in src/red_utils/ext/diskcache_utils/validators.py
validate_key(key=None, none_ok=False)
Validate input diskcache key.
Supported key types: - int - str
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key |
str
|
The key to evaluate |
None
|
none_ok |
bool
|
Allow null keys |
False
|
Returns:
| Type | Description |
|---|---|
str | int
|
The original key after all validations are passed |
Source code in src/red_utils/ext/diskcache_utils/validators.py
validate_read(read=None, none_ok=True)
Validate input diskcache read value.
Read is a bool that enables/disables reading input as a file. Docs: https://grantjenks.com/docs/diskcache/tutorial.html#cache
Only int types allowed. Expiration time is in seconds.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
read |
bool
|
|
None
|
none_ok |
bool
|
none_ok (bool): Allow null values |
True
|
Returns:
| Type | Description |
|---|---|
bool
|
The original value of |
Source code in src/red_utils/ext/diskcache_utils/validators.py
validate_retry(retry=None, none_ok=True)
Validate input diskcache retry.
Determines whether or not cache will retry on failure before exiting.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
retry |
bool
|
|
None
|
none_ok |
bool
|
Allow nullable values |
True
|
Returns:
| Type | Description |
|---|---|
bool
|
The original value of |
Source code in src/red_utils/ext/diskcache_utils/validators.py
validate_tag(tag=None, none_ok=True)
Validate input diskcache tag.
A tag is an optional user-defined string that groups cache entries.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tag |
str
|
A tag to validate |
None
|
none_ok |
bool
|
Allow null values |
True
|
Returns:
| Type | Description |
|---|---|
str
|
A validated tag |
Source code in src/red_utils/ext/diskcache_utils/validators.py
validate_tags(tags=None, none_ok=True)
Validate a list of tags.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tags |
list[str]
|
A list of tags to validate |
None
|
none_ok |
bool
|
Allow null values |
True
|
Returns:
| Type | Description |
|---|---|
list[str]
|
A validated list of tags |
Source code in src/red_utils/ext/diskcache_utils/validators.py
validate_val(val=None, none_ok=False)
Validate input diskcache value.
Supported value types: - int - str
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
val |
str
|
The value to evaluate |
None
|
none_ok |
bool
|
Allow null keys |
False
|
Returns:
| Type | Description |
|---|---|
str | bytes | float | int
|
The original value after all validations are passed |