<?php
# Generated by the protocol buffer compiler.  DO NOT EDIT!
# source: google/cloud/redis/cluster/v1/cloud_redis_cluster.proto

namespace Google\Cloud\Redis\Cluster\V1\ClusterPersistenceConfig\AOFConfig;

use UnexpectedValueException;

/**
 * Available fsync modes.
 *
 * Protobuf type <code>google.cloud.redis.cluster.v1.ClusterPersistenceConfig.AOFConfig.AppendFsync</code>
 */
class AppendFsync
{
    /**
     * Not set. Default: EVERYSEC
     *
     * Generated from protobuf enum <code>APPEND_FSYNC_UNSPECIFIED = 0;</code>
     */
    const APPEND_FSYNC_UNSPECIFIED = 0;
    /**
     * Never fsync. Normally Linux will flush data every 30 seconds with this
     * configuration, but it's up to the kernel's exact tuning.
     *
     * Generated from protobuf enum <code>NO = 1;</code>
     */
    const NO = 1;
    /**
     * fsync every second. Fast enough, and you may lose 1 second of data if
     * there is a disaster
     *
     * Generated from protobuf enum <code>EVERYSEC = 2;</code>
     */
    const EVERYSEC = 2;
    /**
     * fsync every time new commands are appended to the AOF. It has the best
     * data loss protection at the cost of performance
     *
     * Generated from protobuf enum <code>ALWAYS = 3;</code>
     */
    const ALWAYS = 3;

    private static $valueToName = [
        self::APPEND_FSYNC_UNSPECIFIED => 'APPEND_FSYNC_UNSPECIFIED',
        self::NO => 'NO',
        self::EVERYSEC => 'EVERYSEC',
        self::ALWAYS => 'ALWAYS',
    ];

    public static function name($value)
    {
        if (!isset(self::$valueToName[$value])) {
            throw new UnexpectedValueException(sprintf(
                    'Enum %s has no name defined for value %s', __CLASS__, $value));
        }
        return self::$valueToName[$value];
    }


    public static function value($name)
    {
        $const = __CLASS__ . '::' . strtoupper($name);
        if (!defined($const)) {
            throw new UnexpectedValueException(sprintf(
                    'Enum %s has no value defined for name %s', __CLASS__, $name));
        }
        return constant($const);
    }
}


