UPDATE
cscart_lock_keys
SET
expiry_at = UNIX_TIMESTAMP(NOW()) + 30,
token = 'JZ9gDssQEEL2BpXCd6lqvU0BBuj6xxAyc1Ay14E5Qvo='
WHERE
key_id = '8477974678b58a6ddf528bb09e2318a290ab0aa691ee913a3efc2295793c6770'
AND (
token = 'JZ9gDssQEEL2BpXCd6lqvU0BBuj6xxAyc1Ay14E5Qvo='
OR expiry_at <= UNIX_TIMESTAMP(NOW())
)