UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'qGytqMwi0pcl0UAKf3NHpeNKCKkfo/471seFBjqqf+0=' 
WHERE 
  key_id = '24593db43a6a7174e1da9e40f08d6987757392dfca4b6e8a4d31668cebdca372' 
  AND (
    token = 'qGytqMwi0pcl0UAKf3NHpeNKCKkfo/471seFBjqqf+0=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00030