UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'amCldrGjYsG1zengP+w8AasdGqiPR++kq+fGgWBubd4=' 
WHERE 
  key_id = '5655e258478439f946af8ea46630ea83fcc10661647ec9e42e7f293be9585888' 
  AND (
    token = 'amCldrGjYsG1zengP+w8AasdGqiPR++kq+fGgWBubd4=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00035