UPDATE
cscart_lock_keys
SET
expiry_at = UNIX_TIMESTAMP(NOW()) + 30,
token = 'ap5gsBPttdCuLj4Sm8psERh8eUB0PEshN3kba08ER8Q='
WHERE
key_id = 'cc28be7b1525589c5734c1410c319eb1fb4bf062b3cf8e506eca76a39f971d08'
AND (
token = 'ap5gsBPttdCuLj4Sm8psERh8eUB0PEshN3kba08ER8Q='
OR expiry_at <= UNIX_TIMESTAMP(NOW())
)