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