/// <summary>
        /// Writes data to a BerkeleyDb store entry.
        /// </summary>
        /// <param name="typeId">The type of the store accessed.</param>
        /// <param name="objectId">The object id used for store access.</param>
        /// <param name="key">The key of the store entry accessed.</param>
        /// <param name="buffer">The buffer supplying the write data.</param>
        /// <param name="options">The options for the read.</param>
        /// <returns>Whether the write succeeded.</returns>
        /// <exception cref="ArgumentOutOfRangeException">
        /// <para><paramref name="options"/> has a negative offset.</para>
        /// </exception>
        /// <remarks>
        /// <para>Return value is <see langword="false"/> if:</para>
        /// <para><paramref name="typeId"/> isn't valid.</para>
        /// <para>-or-</para>
        /// <para>A <see cref="BdbException"/> was thrown from the underlying store
        /// (Exception is logged but not rethrown).</para>
        /// </remarks>
        public bool SaveEntry(short typeId, int objectId, DataBuffer key, DataBuffer buffer,
                              PutOptions options)
        {
            options.AssertValid("options");
            if (!CanProcessMessage(typeId))
            {
                return(false);
            }
            DebugLog("SaveEntry()", typeId, objectId);
            Database db = GetDatabase(typeId, objectId);

            try
            {
                var size = db.Put(key, options.Offset, options.Length, buffer,
                                  options.Flags);
                if (size != buffer.ByteLength)
                {
                    throw new BdbException((int)DbRetVal.LENGTHMISMATCH, string.Format(
                                               "Expected save length of {0}, got {1}", buffer.ByteLength,
                                               size));
                }
            }
            catch (BdbException ex)
            {
                HandleBdbError(ex, db);
                return(false);
            }
            catch (Exception ex)
            {
                ErrorLog("SaveEntry()", ex);
                throw;
            }
            return(true);
        }
		/// <summary>
		/// Writes data to a BerkeleyDb store entry.
		/// </summary>
		/// <param name="typeId">The type of the store accessed.</param>
		/// <param name="key">The key of the store entry accessed.</param>
		/// <param name="buffer">The buffer supplying the write data.</param>
		/// <param name="options">The options for the read.</param>
		/// <returns>Whether the write succeeded.</returns>
		/// <exception cref="ArgumentOutOfRangeException">
		/// <para><paramref name="options"/> has a negative offset.</para>
		/// </exception>
		/// <remarks>
		/// <para><see cref="DataBuffer.GetHashCode"/> of <paramref name="key"/> is used
		/// as the object id.</para>
		/// <para>Return value is <see langword="false"/> if:</para>
		/// <para><paramref name="typeId"/> isn't valid.</para>
		/// <para>-or-</para>
		/// <para>A <see cref="BdbException"/> was thrown from the underlying store
		/// (Exception is logged but not rethrown).</para>
		/// </remarks>
		public bool SaveEntry(short typeId, DataBuffer key, DataBuffer buffer,
			PutOptions options)
		{
			return SaveEntry(typeId, key.GetObjectId(), key, buffer, options);
		}
		/// <summary>
		/// Writes data to a BerkeleyDb store entry.
		/// </summary>
		/// <param name="typeId">The type of the store accessed.</param>
		/// <param name="objectId">The object id used for store access.</param>
		/// <param name="key">The key of the store entry accessed.</param>
		/// <param name="buffer">The buffer supplying the write data.</param>
		/// <param name="options">The options for the read.</param>
		/// <returns>Whether the write succeeded.</returns>
		/// <exception cref="ArgumentOutOfRangeException">
		/// <para><paramref name="options"/> has a negative offset.</para>
		/// </exception>
		/// <remarks>
		/// <para>Return value is <see langword="false"/> if:</para>
		/// <para><paramref name="typeId"/> isn't valid.</para>
		/// <para>-or-</para>
		/// <para>A <see cref="BdbException"/> was thrown from the underlying store
		/// (Exception is logged but not rethrown).</para>
		/// </remarks>
		public bool SaveEntry(short typeId, int objectId, DataBuffer key, DataBuffer buffer,
			PutOptions options)
		{
			options.AssertValid("options");
			if (!CanProcessMessage(typeId)) return false;
			DebugLog("SaveEntry()", typeId, objectId);
			Database db = GetDatabase(typeId, objectId);
			try
			{
				var size = db.Put(key, options.Offset, options.Length, buffer,
					options.Flags);
				if (size != buffer.ByteLength)
					throw new BdbException((int)DbRetVal.LENGTHMISMATCH, string.Format(
						"Expected save length of {0}, got {1}", buffer.ByteLength,
						size));
			}
			catch (BdbException ex)
			{
				HandleBdbError(ex, db);
				return false;
			}
			catch (Exception ex)
			{
				ErrorLog("SaveEntry()", ex);
				throw;
			}
			return true;
		}
 /// <summary>
 /// Writes data to a BerkeleyDb store entry.
 /// </summary>
 /// <param name="typeId">The type of the store accessed.</param>
 /// <param name="key">The key of the store entry accessed.</param>
 /// <param name="buffer">The buffer supplying the write data.</param>
 /// <param name="options">The options for the read.</param>
 /// <returns>Whether the write succeeded.</returns>
 /// <exception cref="ArgumentOutOfRangeException">
 /// <para><paramref name="options"/> has a negative offset.</para>
 /// </exception>
 /// <remarks>
 /// <para><see cref="DataBuffer.GetHashCode"/> of <paramref name="key"/> is used
 /// as the object id.</para>
 /// <para>Return value is <see langword="false"/> if:</para>
 /// <para><paramref name="typeId"/> isn't valid.</para>
 /// <para>-or-</para>
 /// <para>A <see cref="BdbException"/> was thrown from the underlying store
 /// (Exception is logged but not rethrown).</para>
 /// </remarks>
 public bool SaveEntry(short typeId, DataBuffer key, DataBuffer buffer,
                       PutOptions options)
 {
     return(SaveEntry(typeId, key.GetObjectId(), key, buffer, options));
 }