UPDATE
cscart_lock_keys
SET
expiry_at = UNIX_TIMESTAMP(NOW()) + 30,
token = 'r1BbC4IBuLQoR6AX45kMDCVNlP123RIP5InOoYjLmOM='
WHERE
key_id = '52377af909fd4b79eacc2a5d2a0512470b761c340575ae3a463bc074607962aa'
AND (
token = 'r1BbC4IBuLQoR6AX45kMDCVNlP123RIP5InOoYjLmOM='
OR expiry_at <= UNIX_TIMESTAMP(NOW())
)