neon_arch
commited on
Commit
·
578c7bc
1
Parent(s):
03384d4
🛠️ fix: improve the documentation for the code (#244)
Browse files- src/cache/redis_cacher.rs +15 -0
src/cache/redis_cacher.rs
CHANGED
|
@@ -29,6 +29,11 @@ impl RedisCache {
|
|
| 29 |
/// * `redis_connection_url` - It takes the redis Connection url address.
|
| 30 |
/// * `pool_size` - It takes the size of the connection pool (in other words the number of
|
| 31 |
/// connections that should be stored in the pool).
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 32 |
pub async fn new(
|
| 33 |
redis_connection_url: &str,
|
| 34 |
pool_size: u8,
|
|
@@ -62,6 +67,11 @@ impl RedisCache {
|
|
| 62 |
/// # Arguments
|
| 63 |
///
|
| 64 |
/// * `url` - It takes an url as a string.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 65 |
pub async fn cached_json(&mut self, url: &str) -> Result<String, Report<PoolError>> {
|
| 66 |
self.current_connection = Default::default();
|
| 67 |
let hashed_url_string: &str = &self.hash_url(url);
|
|
@@ -108,6 +118,11 @@ impl RedisCache {
|
|
| 108 |
///
|
| 109 |
/// * `json_results` - It takes the json results string as an argument.
|
| 110 |
/// * `url` - It takes the url as a String.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 111 |
pub async fn cache_results(
|
| 112 |
&mut self,
|
| 113 |
json_results: &str,
|
|
|
|
| 29 |
/// * `redis_connection_url` - It takes the redis Connection url address.
|
| 30 |
/// * `pool_size` - It takes the size of the connection pool (in other words the number of
|
| 31 |
/// connections that should be stored in the pool).
|
| 32 |
+
///
|
| 33 |
+
/// # Error
|
| 34 |
+
///
|
| 35 |
+
/// Returns a newly constructed `RedisCache` struct on success otherwise returns a standard
|
| 36 |
+
/// error type.
|
| 37 |
pub async fn new(
|
| 38 |
redis_connection_url: &str,
|
| 39 |
pool_size: u8,
|
|
|
|
| 67 |
/// # Arguments
|
| 68 |
///
|
| 69 |
/// * `url` - It takes an url as a string.
|
| 70 |
+
///
|
| 71 |
+
/// # Error
|
| 72 |
+
///
|
| 73 |
+
/// Returns the results as a String from the cache on success otherwise returns a `CacheError`
|
| 74 |
+
/// on a failure.
|
| 75 |
pub async fn cached_json(&mut self, url: &str) -> Result<String, Report<PoolError>> {
|
| 76 |
self.current_connection = Default::default();
|
| 77 |
let hashed_url_string: &str = &self.hash_url(url);
|
|
|
|
| 118 |
///
|
| 119 |
/// * `json_results` - It takes the json results string as an argument.
|
| 120 |
/// * `url` - It takes the url as a String.
|
| 121 |
+
///
|
| 122 |
+
/// # Error
|
| 123 |
+
///
|
| 124 |
+
/// Returns an unit type if the results are cached succesfully otherwise returns a `CacheError`
|
| 125 |
+
/// on a failure.
|
| 126 |
pub async fn cache_results(
|
| 127 |
&mut self,
|
| 128 |
json_results: &str,
|