diff --git a/php_stubs/libaerospike-php-stubsv1.0.0.php b/php_stubs/libaerospike-php-stubsv1.0.0.php index e2b0d768..5f66e0ed 100644 --- a/php_stubs/libaerospike-php-stubsv1.0.0.php +++ b/php_stubs/libaerospike-php-stubsv1.0.0.php @@ -4278,6 +4278,7 @@ public function getExpiration(): \Aerospike\Expiration {} /** * Expiration is TTL (Time-To-Live). * Number of seconds until record expires. + * Returns NULL if TTL is set to Never Expire. */ public function getTtl(): ?int {} diff --git a/src/lib.rs b/src/lib.rs index 044bdf86..55e47b6c 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -27,7 +27,6 @@ use std::hash::{Hash, Hasher}; use std::io::Cursor; use std::sync::Arc; use std::sync::Mutex; -use std::time::SystemTime; use byteorder::{ByteOrder, NetworkEndian}; use ripemd160::digest::Digest; @@ -67,7 +66,6 @@ pub type AsResult = std::result::Result; const VERSION: &str = env!("CARGO_PKG_VERSION"); const PARTITIONS: u16 = 4096; -const CITRUSLEAF_EPOCH: u64 = 1262304000; //////////////////////////////////////////////////////////////////////////////////////////// // @@ -4216,8 +4214,10 @@ impl Record { #[getter] pub fn get_expiration(&self) -> Expiration { match self._as.expiration { - 0 => NEVER_EXPIRE.into(), - secs => secs.into(), + NAMESPACE_DEFAULT => Expiration::Namespace_Default(), + NEVER_EXPIRE => Expiration::Never(), + DONT_UPDATE => Expiration::Dont_Update(), + secs => Expiration::Seconds(secs), } } @@ -4226,22 +4226,8 @@ impl Record { #[getter] pub fn get_ttl(&self) -> Option { match self._as.expiration { - 0 => NEVER_EXPIRE.into(), - secs => { - let expiration = CITRUSLEAF_EPOCH + (secs as u64); - let now = SystemTime::now() - .duration_since(SystemTime::UNIX_EPOCH) - .unwrap() - .as_secs(); - - // Record may not have expired on server, but delay or clock differences may - // cause it to look expired on client. Floor at 1, not 0, to avoid old - // "never expires" interpretation. - if expiration > now { - return (((expiration as u64) - now) as u32).into(); - } - return (1 as u32).into(); - } + NEVER_EXPIRE => None, + secs => (secs as u32).into(), } }