UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'LTrzBlSz6XeYHqq6jJULjav+hf24gcuyzSgeBknFemk=' 
WHERE 
  key_id = 'a7b63e762200f6ce45fee6a5b89d33490556ef12588c4c6d9d2099fa08e1912b' 
  AND (
    token = 'LTrzBlSz6XeYHqq6jJULjav+hf24gcuyzSgeBknFemk=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00051