pub struct Cache { /* private fields */ }👎Deprecated since 0.3.0: use
async_cache insteadImplementations§
Source§impl Cache
impl Cache
Sourcepub fn new() -> Result<Self, CacheError>
👎Deprecated since 0.3.0: use async_cache instead
pub fn new() -> Result<Self, CacheError>
async_cache insteadCreates a new Cache instance.
This function establishes a connection to a Redis server and returns a Result containing the Cache instance if successful, or a Boxed error if an error occurs.
§Errors
Returns a Boxed error if:
- The URL for the Redis server is invalid or unreachable.
- The connection to the Redis server cannot be established.
§Example
use celp_sdk::cache::Cache;
let cache = Cache::new();Sourcepub fn add_field(
&mut self,
key: &str,
field: &str,
value: &[u8],
) -> Result<i32, CacheError>
👎Deprecated since 0.3.0: use async_cache instead
pub fn add_field( &mut self, key: &str, field: &str, value: &[u8], ) -> Result<i32, CacheError>
async_cache insteadAdds a field and its corresponding value to a Redis hash.
§Arguments
key- The key of the Redis hash.field- The field to set.value- The value to set for the field.
§Example
use celp_sdk::cache::Cache;
let cache = Cache::new();
if let Ok(mut c) = cache {
c.add_field("celp:app_info", "restful-svc", "serialized-version-str".as_bytes());
}Sourcepub fn get_fields(
&mut self,
key: &str,
) -> Result<HashMap<String, String>, CacheError>
👎Deprecated since 0.3.0: use async_cache instead
pub fn get_fields( &mut self, key: &str, ) -> Result<HashMap<String, String>, CacheError>
async_cache insteadSourcepub fn get_field_names(&mut self, key: &str) -> Result<Vec<String>, CacheError>
👎Deprecated since 0.3.0: use async_cache instead
pub fn get_field_names(&mut self, key: &str) -> Result<Vec<String>, CacheError>
async_cache insteadSourcepub fn get_field_value(
&mut self,
key: &str,
field: &str,
) -> Result<Option<String>, CacheError>
👎Deprecated since 0.3.0: use async_cache instead
pub fn get_field_value( &mut self, key: &str, field: &str, ) -> Result<Option<String>, CacheError>
async_cache insteadRetrieves a specific field’s value from a Redis hash.
§Arguments
key- The key of the Redis hash.field- The field whose value you want to retrieve.
§Example
use celp_sdk::cache::Cache;
let cache = Cache::new();
if let Ok(mut c) = cache {
let value = c.get_field_value("celp:app_info", "field_name");
}Sourcepub fn field_exists(
&mut self,
key: &str,
field: &str,
) -> Result<bool, CacheError>
👎Deprecated since 0.3.0: use async_cache instead
pub fn field_exists( &mut self, key: &str, field: &str, ) -> Result<bool, CacheError>
async_cache insteadSourcepub fn delete_field(
&mut self,
key: &str,
field: &str,
) -> Result<bool, CacheError>
👎Deprecated since 0.3.0: use async_cache instead
pub fn delete_field( &mut self, key: &str, field: &str, ) -> Result<bool, CacheError>
async_cache insteadAuto Trait Implementations§
impl Freeze for Cache
impl !RefUnwindSafe for Cache
impl Send for Cache
impl Sync for Cache
impl Unpin for Cache
impl !UnwindSafe for Cache
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more