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