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