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